cuprite | Headless Chrome/Chromium driver for Capybara | UI Testing library
kandi X-RAY | cuprite Summary
kandi X-RAY | cuprite Summary
Cuprite is a pure Ruby driver (read as no Selenium/WebDriver/ChromeDriver dependency) for Capybara. It allows you to run Capybara tests on a headless Chrome or Chromium. Under the hood it uses Ferrum which is high-level API to the browser by CDP protocol. The design of the driver is as close to Poltergeist as possible though it's not a goal. Cuprite website is designed & supported by Evrone What else we build with Ruby.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of cuprite
cuprite Key Features
cuprite Examples and Code Snippets
Community Discussions
Trending Discussions on cuprite
QUESTION
In ruby 2.6.1, rails 6.0 I am trying to get Capybara to start a test server and have the option to show or not the cases on chrome using capybara 3.35.3 and cuprite 0.13, by setting a headless option on or off.
My findings and issues:
Ideally Not define Capybara.server_host
or Capybara.server_port
and instead use Capybara.always_include_port = true
which according to Capybara's documentation, is meant to always send or rather append the port to the server host address for whenever visit is used in a test case, the url in the browser would be http://127.0.0.1:xxxx/
. The problem with this approach is that Capybara.always_include_port
is not doing that, instead after the server is run, the browser goes to http://127.0.0.1/
If I set Capybara.server_port
, the browser still ends up with no port upon bundle exec rspec, regardless to the state of Capybara.always_include_port
.
for reference, the reason I use CAPYBARA_APP_HOST
with host!
before each case and not use a general Capybara.app_host
is because Rails automatically changes the value of the latter to 127.0.0.1
, so this is more of a work around acquired from evilmartians.
The commented lines of code are to showcase my points mentioned.
worth noting that the only way currently the environment would work is if I set Capybara.run_server = false
, and uncomment the server_host
, server_port
, CAPYBARA_APP_HOST
and host!
lines, and start a seperate rails server using rails s
then run the specs, which is less than ideal.
Any pointers? Thank you
my rails_helper.rb:
...ANSWER
Answered 2021-Jun-05 at 10:32so I decided to debug lib/capybara/session.rb
and noticed that always_include_port
is actually working as it should be, and the outcome is indeed to initiate a driver with a full uri; a url + port.
The problem was a warning that I have been ignoring when running specs about having force_ssl if: :ssl_configured?
within the application controller. I hashed out that line and all is working as expected.
Lesson: do not ignore runtime warnings.
QUESTION
It appears that the object logged to console does not match what is displayed on the HTML, I'm puzzled by this simple example below. Here the button toggles the ordering of the array, and React seems to render the previous list.
=== Update 3 ====
The cuprite is object compassion where setState(list=>list.push(12))
will mutate the list but won't trigger setState because the id of the list is still the same.
If you update a State Hook to the same value as the current state, React will bail out without rendering the children or firing effects. (React uses the Object.is comparison algorithm.) React useState doc
=== Update 2 ====
I think I found the solution. The culprit seems to be the mutability of objects, and the workaround is to create a deep copy of the sorted list in Solution Sandbox. I believe I found an undefined behaviour of React, since the mutability of list should not cause any differences in console.log(list)
and
list
shown in the image below. Correct modification of state arrays in ReactJS
=== Update 1 ====
Sandbox which contains the same code as the one shown below.
There is nothing wrong with my sort function! If ascending, then the smaller element should come first, which means the comparison function (e1,e2)=>e1-e2
is correct.
...If compareFunction(a, b) returns less than 0, sort a to an index lower than b (i.e. a comes first). Comparision function Mozilla
ANSWER
Answered 2020-Oct-25 at 06:35You have closure on list
value at the useEffect
callback, you should add it to your dep array:
QUESTION
I'm switching from the Poltergeist to Cuprite driver for Capybara.
I have Javascript code which sets the message for a confirmation modal which I want to check in my feature specs.
The javascript is confirm("....")
.
With Poltergiest I could do page.driver.browser.modal_message
.
This is unsupported by Cuprite, it there another way?
...ANSWER
Answered 2019-Sep-16 at 15:32Looking at the ferrum driver which Cuprite uses under the hood I can see it is possible register a hook for a dialog appearing.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install cuprite
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page