Failed to connect to SafariDriver (Safari 10) - safari

I'm getting the following error when running my protractor test on mac for safari
Failed to connect to SafariDriver after 10082 ms
Build info: version: '2.53.1', revision: 'a36b8b1',
os.arch: 'x86_64', os.version: '10.12.2', java.version: '1.8.0_101'
Driver info: driver.version: SafariDriver
capability:
name: 'Safari',
browserName: 'safari',
logName: 'Safari',
shardTestFiles: true,
maxInstances: 2
Do we need a specific safari driver for this? If yes, where can I get it from and where should it be declared in the .conf file.
Thank you!

Yes, you need to install a specific safari driver in order to launch it inside of protractor. And of course, you need to be on a mac. Protractor is essentially a layer built on top of Selenium, so you need to install the selenium driver for Safari, which is implemented as a Safari plugin.
Here is what you need to do:
Download the safari plugin from here.
Run the plugin
Select "Trust" the plugin when prompted by safari
The driver is now installed and should be available to your protractor process.
This is the driver for Selenium 2.48. I couldn't find a more recent build, so if this driver version doesn't run with the current version of Protractor, you will need to either use an older version of protractor that is based on Selenium 2.48 or build the safari driver from source.

First of all, starting with Safari 10, Safari comes bundled with a new driver implementation. The old driver (the extension) is deprecated. You're using macOS 10.12.2, so it's your case. To enable the new driver in Safari, toggle the Allow Remote Automation checkbox in the Develop menu. If you don't have this menu, enable it: Preferences > Advanced > Show Develop menu in menu bar. Start /usr/bin/safaridriver once manually to grant it the permissions needed.
Secondly, you need a 3.x version of the Selenium Standalone Server, not 2.53.1. The command to install it:
sudo webdriver-manager update --versions.standalone 3.0.1
To start:
webdriver-manager start --versions.standalone 3.0.1
Thirdly, the visibility checks are broken in the new driver. So things like browser.wait(ExpectedConditions.visibilityOf(myElement), 5000); don't work and lead to UnsupportedCommandException. In order to fix this, you can try installing Safari Technology Preview and running tests there (add 'safari.options': { technologyPreview: true } to the capabilities). But for me, the preview works even worse than the release. Protractor says it can't find Angular on the page because they changed window.name to be cleared after a cross-origin navigation in the Release 19. If you happen to find a way to make it work, please let me know.
Below are some links you should check because I might have missed something.
The blog post that announces the new driver in Safari 10
Issues in the Protractor project:
Safari 10 failing with the latest protractor
Safari Technology Preview can't find Angular 1

Related

How do I get version of Chrome on Selenium Node?

I'm learning how to run tests on SeleniumGRID.
I have problem with specifying the version of Chrome browser.
I have 1 Selenium Hub and 1 Selenium Node connected to the Hub.
Selenium Node has Chrome browser. The version of browser is:
85.0.4183.102
If I use:
DesiredCapabilities capability = new DesiredCapabilities();
capability.setBrowserName("chrome");
capability.setCapability("platform", "Linux");
it will work fine. But if I add:
capability.setCapability("version", "85.0");
I will get error:
org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities {browserName: chrome, platform: LINUX, version: 85.0}
What should I put in version to run it?
I was trying various possibility (85, 85.0, 85.0.4183.102) but neither of them worked.
I think it's because Node probably doesn't have specified the Chrome version.
I ran the Node with configuration in json file. Then I was able to specify the Chrome version in this json file.
And then I was able to run tests with specified chrome version.

Showing Error - unknown error: DevToolsActivePort file doesn't exist - it's electron application (I am using windows OS))

When I run my code it's showing below error - Electron application
org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist.
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'DESKTOP-GN8LLQU', ip: '192.168.1.20', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.2'
Driver info: driver.version: ChromeDriver
My Code:
ChromeOptions opt = new ChromeOptions();
// path of your Electron Application
opt.setBinary("D:\\FOS\\fiber-optic-system-electron\\release\\angular-electron 0.1.0.exe");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("chromeOptions", opt);
capabilities.setBrowserName("chrome");
System.setProperty("webdriver.chrome.driver", "E:\\chromedriver_win32 (6)\\chromedriver.exe");
WebDriver driver = new ChromeDriver(capabilities);
I have been experiencing the error DevToolsActivePort file doesn't exist myself and in my case the error was correct and the root cause was the electron app itself.
Since v2.39 Chrome's web driver (chromedriver.exe) by default looks for a file named DevToolsActivePort and when found reads it to obtain the port number of devtools that is currently running in chrome (and in your case the Chrome instance that the electron app "angular-electron 0.1.0.exe" is running).
When you create a ChromeDriver in Selenium and include the --remote-debugging-port=0 argument, or otherwise do not include this argument at all, then chromedriver will send --remote-debugging-port=0 in the command line to your electron app (ie. angular-electron 0.1.0.exe). If your electon app passes this argument onto the Chrome app running inside it then the DevToolsActivePort file is created, chromedriver can read it and gain the port of devtools, and automation is successful. However if your electron app does not pass this argument to Chrome then the DevToolsActivePort file is never created and your chromedriver times out looking for it and fails.
You have a couple of options for a solution:
Have the developers of the electron app ensure the "--remote-debugging-port" argument is passed onto Chrome.
Automate your own solution for creating the "DevToolsActivePort" file.
In my case I went with option 2. Here's how you can test this option manually. If you run an application like SysInternal's Tcpview (https://learn.microsoft.com/en-us/sysinternals/downloads/tcpview) before your electron app then Tcpview will show you the ports that your electron app is listening on. One of these ports will be the Chrome's devtools port. Note this down. Now go into your %temp% folder in Windows as this is the default location for the temporary folder containing the DevToolsActivePort file that chromedriver is looking for. In this folder look for the folders prefixed with scoped_dir. By default chromedriver will create one these each time you run it. To guarantee you access the correct folder it's best to set this directory name yourself beforehand in chromedriver using the --user-data-dir argument before running it. Go into this folder and create a new file named DevToolsActivePort and enter the port number on the first line, press Enter (newline), and then any number on the second line. Save the file and close. If you complete this entire process manually within 60 seconds the running chromedriver will read that file, get the port of Chrome's devtools, connect to it and continue.
I have developed an AutoIT script that does the above process automatically and I include this in my own automation runs and works every time.
Hope this helps.
This error message...
org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist.
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'DESKTOP-GN8LLQU', ip: '192.168.1.20', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.2'
Driver info: driver.version: ChromeDriver
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
Possibly you are using the latest chromedriver=77.0
Possibly you are using_chrome= 77.0_
Your Selenium Client version is 3.6.0 of 2017-09-27T15:28:36.4Z which is almost 2 years older.
Your JDK version is 11.0.2.
So there is a clear mismatch between the Selenium Client v3.6.0 , ChromeDriver v77.0 and the Chrome Browser v77.0
Solution
Ensure that:
Selenium is upgraded to current levels Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v77.0 level.
Chrome is updated to current Chrome Version 77.0 level. (as per ChromeDriver v77.0 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test as non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
Note: As per Unable to import org.openqa.selenium.WebDriver using Selenium and Java 11 it may be a better idea to downgrade to Java 8
Outro
WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser
Although this is an old question but want to add my answer here, it may help someone.
My environment was [ When I can see the same error ] :
Windows 10
Selenium 3.14
Chrome driver 85.0.4183.87
Browser version for electron app is 85.0.4183.121
[ Sidenote : I am trying to automate Microsoft Teams and it is an electron app ] .
After searching a lot through internet came to conclusion that it is somehow a version mismatch . Finally this github issue link backed my theory and the ChromeDriver 2.37.544315 attached in its answer worked for me.
My code is similar to what we see in the SO question.
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver\\chromedriver.exe");
ChromeOptions opt = new ChromeOptions();
opt.setBinary("C:\\Users\\<MyUserName>\\AppData\\Local\\Microsoft\\Teams\\current\\Teams.exe");
WebDriver driver = new ChromeDriver(opt);
and output is [ As expected : Teams opens up without any error ]:
Starting ChromeDriver 2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7) on port 2389
Only local connections are allowed.
Jan 12, 2022 1:23:57 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS

Which Selenium standalone version is compatible with Firefox version 58.0

Which Selenium standalone jars are compatible with Firefox version 58.0?I tried 2.46.0 selenium jars and I am getting this exception:
org.openqa.selenium.WebDriverException:
Unable to bind to locking port 7054 within 45000 ms
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:17:10'
System info: host: 'CHDSEZ400598D', ip: '10.152.107.68', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_77'
Mozilla Firefox Browsers are released as GA (General Availability) versions irrespective of Manual or Automation testing. It's the GeckoDriver which controls the Mozilla Firefox Browser through Marionette. Again its the Selenium Client which initializes the GeckoDriver. So the compatibility rests partially with Selenium Client and partialy with GeckoDriver.
Though Selenium releases are made with outmost effort to keep the Selenium Clients backward compatible with the previous releases of GeckoDriver and Firefox Browser releases but the last dependency announced as per the Selenium Release Notes is as follows :
v3.4.0
======
* Geckodriver 0.16 is strongly recommended
The last announced dependency of GeckoDriver 0.19.0 (2017-09-16) is as follows :
0.19.0 (2017-09-16)
Note that with geckodriver 0.19.0 the following versions are recommended: - Firefox 55.0 (and greater) - Selenium 3.5 (and greater)
Solution
An effective solution would be as follows :
Update your JDK version to the latest version, currently vJDK 8u162
Update your Selenium Client version to the latest version, currently v3.10.0
Update your GeckoDriver version to v0.19.1 (2017-10-30)
Update your Firefox Quantum Browser version to [v58.0.2]
Clean your Project Workspace and Rebuild your project with required dependencies only.
Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
If your base Firefox version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Firefox.
Execute your #Test.

geb.driver.DriverCreationException: failed to create driver from callback

I am getting below Exception while running test scripts.
geb.driver.DriverCreationException: failed to create driver from callback 'script1501516684770944233575$_run_closure1#6601cc93'
java.lang.NoClassDefFoundError: Lorg/openqa/selenium/remote/html5/RemoteWebStorage;
failed to create driver from callback 'script1501516684770944233575$_run_closure1#6601cc93'
OS: Windows 10 64 bit
Chrome browser: v60 (latest one)
Selenium :-2.43.1
Chrome web driver:-2.24.417431
geb-version:0.10.0
geb-testng-version:0.13.1
geb-spoc-version:0.13.1
Thanks in Advance...!
This will be a version issue (your old web driver is not compatible with newer chrome versions). If you are using the latest version of chrome, I suggest moving to the latest version of selenium and chrome driver.
Infact one quick google suggests that I might be right: https://sites.google.com/a/chromium.org/chromedriver/downloads
Latest Release: ChromeDriver 2.31
Supports Chrome v58-60
This error can be thrown if you do not correctly define your chrome driver location when executing your tests.
Either in your GebConfig:
driver = {
System.setProperty('webdriver.chrome.driver', '/Users/foo/drivers/chromedriver')
new ChromeDriver()
}
Or in something like VM parameters if running from an intelliJ Run/Debug Configuration:
-Dbrowser=chrome -Dwebdriver.chrome.driver="/Users/foo/drivers/chromedriver/chromedriver.exe"
I was having this problem for a couple of days and finally understand the cause. This problem occurred for me on Jenkins when I am setting my browser to chrome or firefox and then trying to run my tests. It occurred due to browsers not installed on Jenkins machine. The drivers are present in the code but the browser should be installed on machine otherwise Geb will throw this error. Hope this helps.

Firefox 47.0, selenium selenium-java-2.53.0 windows64 org.openqa.selenium.remote.UnreachableBrowserException

Using Mars.2 Release (4.5.2) and Firefox 47.0 to run my selenium code but every time I hit run I am getting this
StackTrace:
"Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException:
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure."
Firefox 47.0 came out recently and to use it a new driver must be used that is made by Mozilla instead of by Selenium. See Marionette Driver
Download this driver and make sure the executable file is in your system path. Now you need to change your program so that it uses this driver by setting a desired capability:
dc = DesiredCapabilities.FIREFOX
dc['marionette'] = True
driver = webdriver.Firefox(capabilities=dc)
Downgrade your firefox version to FF 46.0 as the FF 47.0 has no support for webdriver. once you downgrade the Firefox go and disable the auto upgrade option by following the below mentioned steps:
Open firefox: Press F10 > Tools > options
Go to the Advanced tab
Navigate to the Update tab
Uncheck the option 'Use a background service to install update'
Uncheck 'Automatically install updates (recommended: improved security)' and click ok