Here's simple batch file I wrote to start the node for selenium grid
set webdriver.ie.driver=C:\selenium-server\IEDriverServer.exe
echo %webdriver.ie.driver%
set webdriver.chrome.driver=C:\selenium-server\chromedriver.exe
echo %webdriver.chrome.driver%
java -jar selenium-server-standalone-2.32.0.jar -role hub
Yes both drivers exist in that directory and I've even added that directory to my System's Path variable. When I try to create a remote web driver like thus:
Platform platform = Platform.WINDOWS;
desiredCapabilities =new DesiredCapabilities("internet explorer", "9.0", platform);
driver = new RemoteWebDriver(new URL(gridUrl), desiredCapabilities);
I'm still getting an exception stating:
Exception: The path to the driver executable must be set by the webdriver.ie.driver system property; for more information, see htt
/p/selenium/wiki/InternetExplorerDriver. The latest version can be downloaded from http://code.google.com/p/selenium/downloads/list
I'm using the latest IEDriver and chromedriver and selenium server 2.32.0 (which I believe is the latest one too).
Running on windows 7. I've tried both the 32 and 64 bit drivers for IE. Get the same problem with the chrome driver.
Adding this option at the end of the command to start my node got everything working. Is this just poorly documented? did I miss something obvious? or is there still something weird going on?
-Dwebdriver.ie.driver=C:\selenium-server\IEDriverServer.exe
Related
I am trying to set up a selenium grid using the latest chrome and chromedriver. I get the following error when trying to run a test
Message: OpenQA.Selenium.WebDriverException : Unexpected error. Host header or origin header is specified and is not localhost.
On the node machine, I see the chrome browser open, but then it immediately closes and I get this error:
[1557513678.682][SEVERE]: Rejecting request with host: <hub_IP_address>:4444
Has anyone had this issue using the selenium grid? I am using:
selenium-server-standalone-4.0.0-alpha-1.jar and
Chromedriver 74.0.3729.6 for windows
My Chrome browser was running v.74.0.3729.108
JDK 12.0.1.0
Here is my command for starting the hub:
java -jar selenium-server-standalone-4.0.0-alpha-1.jar -role hub -hubConfig config.json
Here is my command to start a node:
java -Dwebdriver.chrome.driver="C:\...\Browsers\ChromeDirectory\chromedriver.exe" -Dwebdriver.ie.driver="C:\...\Browsers\IEDirectory\x86\IEDriverServer.exe" -jar -Dwebdriver.edge.driver="C:\...\Browsers\Edge\MicrosoftWebDriver.exe" -jar "C:\...\selenium-server-standalone-4.0.0-alpha-1.jar" -role node -hub "http://<hub_IP_address>:4444/grid/register/" -nodeConfig "C:\...\config.json"
I tried using a "host" property in the config.jsons. I tried putting the actual IP address and just localhost. But the hub and the node are obviously different machines, so putting localhost makes it so they can't connect. But when I dont have localhost, it says it needs to be specified as localhost? I'm so confused!! What is supposed to go in the host property?
I have seen people talk about a loopback property for protractor but I am not using protractor. I tried putting "loopback":true into both my node and hub config.json files but it doesn't seem to make a difference.
UPDATE:
I was able to get the grid to run successfully using the 4.0 alpha jar for the hub, and the old 3.8 jars for the nodes. All Still on Java 8. Kind of interesting.
You can try to add these switches: --whitelisted-ips --allowed-origins=''*
Try to run your node with command:
java -Dwebdriver.chrome.driver="C:\...\Browsers\ChromeDirectory\chromedriver.exe --whitelisted-ips --allowed-origins='*'" -Dwebdriver.ie.driver="C:\...\Browsers\IEDirectory\x86\IEDriverServer.exe" -jar -Dwebdriver.edge.driver="C:\...\Browsers\Edge\MicrosoftWebDriver.exe" -jar "C:\...\selenium-server-standalone-4.0.0-alpha-1.jar" -role node -hub "http://<hub_IP_address>:4444/grid/register/" -nodeConfig "C:\...\config.json"
I was able to get the selenium grid working by downgrading to 3.8.1 selenium grid jar and installing JDK 8 instead of 12. The reason I needed to get java 8 is answered in this other question. I used the same chrome driver and start up commands
I have the following setup:
A Selenium server hub running at "http://localhost:hubPortNum" (a service with the Jar file selenium-server-standalone-3.141.5.jar with parameter -role hub).
A Selenium Node at running "http://localhost:nodePortNum' (the service with Jar file with parameters: -Dwebdriver.chrome.driver=ChromeWebdriverPath -role node -port :nodePortNum).
I checked the URL for the hub and node instances to be sure they are working.
Whenever I try to create Remote Webdriver via Python script:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
desiredCapabilities = DesiredCapabilities.CHROME.copy()
chromeOptionsRemote = webdriver.ChromeOptions()
chromeOptionsRemote.add_argument("--start-maximized")
chromeOptionsRemote.add_argument("--disable-session-crashed-bubble")
initRemoteDriver = webdriver.Remote(options=chromeOptionsRemote, command_executor='http://127.0.0.1:<nodePortNum>/wd/hub', desired_capabilities=desiredCapabilities)
print(initRemoteDriver.current_url)
The last line does print the current URL(which is "data:,"), that means Webdriver is created.
But the browser does not open on my local machine, that is it is running in the background and I don't know how to make it visible although it has worked in the past.
The troubleshooting steps I have made:
Reinstall latest selenium python package.
Re-Download latest Selenium server jar file.
Updating chrome.
adding chromeOptionsRemote.add_argument("--no-sandbox")
Making sure local Webdriver does open:
That is the line:
self.localDriver = webdriver.Chrome(options=chromeOptionsLocal,
desired_capabilities=desiredCapabilities)
does open the browser locally(the Chromedriver is in the path).
After I made these troubleshooting steps, I have tried the same configuration on a remote server and got the same result(browser not visible), so I think this is probably by design.
what configuration should I create for the browser to be visible?
Any help would be appreciated.
I was running the jar file by Always-Up: https://www.coretechnologies.com/products/AlwaysUp/
The problem was related to session 0 isolation: https://stackoverflow.com/a/26752251/2710840
in order to not run the application under session 0, I have enabled the Autologon feature:
defined the user under the application run as my user:
and executed the application from the context menu with the option to: "restart in this session"
I'm trying to execute Selenium with Chrome on Ubuntu 16.04 and what I do is:
Xvfb :10 -screen 0 1366x768x24 -ac &
google-chrome --remote-debugging-port=92222
When I execute the previous command I got this error:
vagrant#smart:~$ [2207:2332:1118/135124.679982:ERROR:bus.cc(394)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
DevTools listening on ws://127.0.0.1:9222/devtools/browser/39519bf4-dad5-4557-86d7-29bde71ee025
(google-chrome:2207): LIBDBUSMENU-GLIB-WARNING **: Unable to get session bus: Unknown or unsupported transport 'disabled' for address 'disabled:'
[2207:2207:1118/135124.939100:ERROR:gpu_process_transport_factory.cc(980)] Lost UI shared context.
[1:8:1118/135125.063874:ERROR:command_buffer_proxy_impl.cc(100)] ContextResult::kFatalFailure: Shared memory region is not valid
I run the selenium command:
java -jar selenium-server-standalone-3.141.5.jar
And when I try to create a session manually through the url I got what I show in picture.
I'm trying to work with some test with codecpetion and yii2 but initially I can't because of that. I'm using the lastest version of all components and I was working perfectly until today. As well I have chromedriver. What is happening?. I am running in a vagrant box and I'm trying to test my application with codeception and I have tried to reinstall selenium and chrome and I got nothing, Thanks so much.
It is because of a conflict between chromedriver, selenium and chrome. Downgrading chrome, it's solved
I have some selenium tests written in java and built using maven. The pom file includes the jbehave and selenium libraries. It uses firefox browser. So I installed firefox on linux and included the path in my .bashrc. If I do a mvn clean install manually , it works fine.
But if I try the same thing using Jenkins ( am trying to automate the tests), it is throwing errors:
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] null
Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: LINUX
Caused by: org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: LINUX
I tried doing an echo of PATH within Jenkins and it did not show the path of firefox. So I also did an export PATH with the new path of firefox included and then called mvn clean install in Jenkins. Even though the PATH now showed the path of firefox in jenkins console output, it still throws the same error.
What is that I am missing?
Three things to check:
1) as #shawnzhu said, check whether you have installed firefox properly?
2) To provide Binary path to your driver, you need to set system property. Use below code for selenium with java:
File firefoxPathBinary = new File("path/to/your//firefox-bin");
System.setProperty("webdriver.firefox.bin", firefoxPathBinary.getAbsolutePath());
driver = new FirefoxDriver();
3) For Ubuntu, path to your firefox executable could be - usr/lib/firefox/firefox-bin and for Mac it could be /Applications/Firefox.app/Contents/MacOS/firefox-bin
You probably need to link the executable:
sudo unlink /usr/bin/firefoxsudo ln -s /path/to/new/firefox/executable /usr/bin/firefox
I have a problem with Selenium and can't get it to work.
What I want to do:
A customer of ours sends us a Selenium test case which shall be executed automatically in several locations and the time taken shall be recorded.
We want to use Selenium and Firefox Portable, because we want to make the tests completely independent of any user input and the installed software at the different locations.
So much for the starting conditions ;)
What we did so far:
The first version was completely written in Java, we exported the test case from the customer to Java with the Selenium IDE Plugin -> Export to Java WebDriver.
This cannot be done anymore, because the customer now uses some functions the WebDriver export does not support. And as we don't want to alter the test from the customer, Java export is no longer an option.
So for the first run we are using this command (any variables are set correctly):
java -jar selenium-2.33.0/selenium-server-standalone-2.33.0.jar -port 5555
-firefoxProfileTemplate "Firefox\Data\profile" -log logs\selenium_server.log
-htmlSuite "*firefox" http://localhost:5555 Testsuite.html
logs\results-firefox-%curTimestamp%.html
This starts my preinstalled firefox, not the portable one. On the customers machine, no firefox is started whatsoever, because it is not installed. So I had to provide the path to the firefox instead, using the "custom" htmlSuite:
java -jar selenium-2.33.0/selenium-server-standalone-2.33.0.jar -port 5555
-firefoxProfileTemplate "Firefox\Data\profile" -log logs\selenium_server.log
-htmlSuite "*custom %FF_DIR%\FirefoxPortable.exe" http://localhost:5555 Testsuite.html
logs\results-firefox-%curTimestamp%.html
This does not work, as the Selenium Server cannot execute this command if run under Windows, which we do (see: http://code.google.com/p/selenium/issues/detail?id=3274)
As comment #6 has some diffs, we patched the selenium Server standalone Jar and ran the test again. Now the browser could be started, but the test could not be run. After the first page loaded we get the error "Permission denied to access property 'document'".
A solution here suggests, a user-rights problem could be the cause and you should try the "chrome" htmlSuite (see: https://sqa.stackexchange.com/questions/1453/how-to-fix-permission-denied-to-access-property-document)
So we did:
java -jar selenium-2.33.0/selenium-server-standalone-2.33.0-patched.jar
-port 5555 -firefoxProfileTemplate "FirefoxPortable\Data\profile"
-log logs\selenium_server.log -htmlSuite "*chrome %FF_DIR%\FirefoxPortable.exe"
http://localhost:5555 Testsuite.html logs\results-firefox-%curTimestamp%.html
Notice our "patched" selenium and the "chrome" htmlSuite.
That didn't work, as well.
So, here in short the results:
htmlSuite = firefox: the preinstalled Firefox is used, if installed, not the Portable one. In case, no FF is installed, the test fails altogether
htmlSuite = chrome: the server cannot start the browser, as it tries to set EnvironmentVariables, which is not supported running Windows (see: http://code.google.com/p/selenium/source/browse/java/client/src/org/openqa/selenium/os/WindowsProcessGroup.java#67 lines 67 following)
htmlSuite = googleChrome: Google Chrome Portable can be started, but the Chrome browser cannot find some elements specified by the test, so we cannot use Chrome (altering the test is no option, as stated above)
htmlSuite = iexplore: Internet Explorer starts, but then a JavaScript error appears, referencing a custom Profile created by Selenium, so the test does not work in IE, either
htmlSuite = custom: the Portable Firefox is started (yeehaw), but does not have sufficient rights to execute the test.
You may use a Continuous Integration System like Jenkins, or TeamCity to execute your tests automatically.
we have now decided to support the customer in installing Firefox on the machines to test, so we can use our batchfile without problems.
As for the bug in selenium look here (code.google.com/p/selenium/issues/detail?id=5554#c14), there is a link to a nightly build that does work (at least for us) with Firefox v23, which Selenium 2.33 does not.
Thanks for everyone who contributed, but I think my first approach can not be achieved the way I thought it could :(
I solved this problem.
Visit this link: http://www.townx.org/blog/elliot/dealing-self-signed-ssl-certificates-when-running-selenium-server-firefox
Point 9:
Delete everything in the directory except for the cert_override.txt and cert8.db files.
Hope it helps