My mac auto-updated safari to v12.1, but now I can't run my nightwatch tests against safari. I just always get the error: "Request body does not contain required parameter 'capabilities'.". I think it's related to this issue: https://github.com/SeleniumHQ/selenium/issues/6431
Is there anything I can update or do inside of nightwatch to get the tests to run again?
Turns out safari made some huge breaking changes in v12. They removed support for the Selenium JSON wire protocol and now only support w3c WebDriver protocol. There isn't much you can do from a nightwatch config standpoint to fix this. Just try to find the w3c equivalent command for what you are trying to do and use that instead.
Ref: https://developer.apple.com/documentation/webkit/macos_webdriver_commands_for_safari_12_and_later
Related
We are using phantomjs browser in robot script and have a requirement to set the phantomjs custom header as a part of capability. Below is the code snippet we have tried
${dc} Evaluate sys.modules['selenium.webdriver'].DesiredCapabilities.PHANTOMJS sys, selenium.webdriver
Set To Dictionary ${dc} phantomjs.page.customHeaders.Authorization=Basic <Credentials>
${service args}= Create List --proxy=localhost:8080 --web-security=false --ignore-ssl-errors=yes --ssl-protocol=ANY --load-images=yes
Create Webdriver PhantomJS service_args=${service args} executable_path=/usr/sap/ljs/webapps/s4c/WEB-INF/classes/WebDriver/phantomjs desired_capabilitie=${dc}
This is code is failing to launch the browser. We didn't find concrete documentation for setting capability to phantomjs in robot. If anyone tried setting custom header to phantomjs in robot framework please suggest us.
Perhaps stating the obvious: none of your end users are using the system under test with PhantomJS which significantly lowers confidence of the achieved results. So for that reason I strongly suggest putting effort in getting the right environment setup so that the test mimic end user situation as close as possible.
It is very likely that you're using a modern version of Selenium that no longer supports PhantomJS as it is Deprecated as of Selenium 3.6.0 and removed as of 3.7.0. Releases.
So if your pip list shows a Selenium Module version of 3.6.0 or higher you may want to downgrade.
Does anyone know how to detect selenium/webdriver browsing on my site?
I don't want to block them, just detect them.
I saw this question:
Can a website detect when you are using selenium with chromedriver?
But trying all of these on latest version didn't seem to work.
Any body knows anything else?
P.S. please don't leave answers/comments of "dont block"/"you are looking in the wrong place" - I am fully aware of what I'm asking and what will be the business logic to use it.
-- EDIT --
Things I have tested from the link above:
detecting cdc_asdjflasutopfhvcZLmcfl_ key on elements, mostly on window and document but some other elements we have across the entire site.
Searching for window.navigator.webdriver always returns undefined instead of true (tested on both chrome and firefox although only firefox said to support it)
tested the script from this answer: https://stackoverflow.com/a/45814390/1593987
All tests were done using latest selenium, browsers (firefox and chrome), and latest webdriver plugins. for now only on windows, but will probably test ubuntu as well.
In recent versions of Selenium WebDriver it's handled on a spec level.
There is a read-only JS property - navigator.webdriver which is true in case webdriver is used to control browser.
Checked with Chrome v73 - returns true.
References:
Spec - https://w3c.github.io/webdriver/#dom-navigatorautomationinformation-webdriver
Firefox - https://developer.mozilla.org/en-US/docs/Web/API/Navigator/webdriver
Chrome - https://www.chromestatus.com/feature/6216034532982784
I have a series of automated tests that use selenium, specifically Geb with Spock. When I run all my tests cases one after another using a chromedriver, my tests run fine. Each test method gets a new session and therefore start with a fresh browser each time. This is not the case when using phantomJS. If a test method happens to fail when using phantomJS, all following test cases will fail because the session was not reset. I can see this happening because the screenshots taken at the end of each test method.
I have tried researching this issue and have discovered it has been a known issue for a couple of years now. Some say it was fixed in phantomjs 2.1 but I'm currently using version 2.1.1, which is the most recent version.
I have also tried using driver.manage().deleteAllCookies(); with no luck, as other threads have mentioned.
Is there a workaround anyone is aware of?
have you tried webdriver's quit method?
When you attempt to run Selenium tests in a scripting context whose origin is at "safari-extension://...", the session hangs. I believe the problem is caused by extension sandboxing, which means if I get Selenium running in the same origin as the extension I am testing, it should be possible to execute selenium commands in my extension.
Question: Can I incorporate the Safari Driver into my Safari extension during testing to circumvent sandboxing?
We modified the Safari driver to navigate extension:// pages, and the problem persists. It looks like Apple blocks Selenium at the extension level :(
I want to run my Geb specs with chrome driver without having to watch the tests on the browser? can this be done?
P.D.: I know I can use the HtmlUnitDriver, but this driver sometimes gives my errors (caused mainly by timeouts) that the chrome driver don't.
There is currently no way to do this with Chrome, Safari, Opera or FireFox, however there are multiple options you can do. First is to pipe the "window" into a virtual frame buffer (if you're using Linux). This process will pop open the browser, only in memory. I talk about this in my blog post (http://www.ensor.cc/2011/05/maven-javascript-unit-test-using.html) during the maven pre-integration phase
The other option is to use the brand new GhostDriver. GhostDriver is a WebDriver implementation of PhantomJS which is a headless WebKit. This is WAY better than HtmlUnit but still has some features being built out. GhostDriver is currently not in Maven Central, so you will need to manually add it to the common repository. You can then use it as a WebDriver. This has worked for me with moderate success (90% of my test cases dropped in without any changes needed).
Read this first: http://blog.ivandemarino.me/2012/12/04/Finally-GhostDriver-1-0-0
Then refer to the GitHub README and code: https://github.com/detro/ghostdriver