Python Selenium Remote Webdriver(Chrome Webdriver via Selenium Grid), created but does not open browser - selenium

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"

Related

Getting Chromedriver logs from standalone Selenium Chrome instance

Summary: How do I extract Chromedriver logs when running Selenium standalone Chrome instance? I.e. interacting via Selenium API commonly on port 4444.
Details:
We are using Protractor to connect to a container running the Docker image selenium/standalone-chrome Selenium "grid". Connection info is specified via the HUB_PORT_4444_TCP_ADDR environment variable. The connection URL ends up being http://localhost:4444/wd/hub. This works fine and our tests are running successfully in Jenkins.
For completeness I'd like to extract the Chromedriver logs and attach them to the build in case we need more info for debugging test failues. How can that be done?
This question seemed like a close match but they are running Chromedriver directly. I need to ask Selenium to provide them somehow.
Log properties of standalone chrome container can be configured using JAVA_OPTS.
You can add JAVA_OPTS environment variable to standalone chrome container
name: JAVA_OPTS
value: "-Dwebdriver.chrome.logfile=<Path to log file, with file name>"
We had a shared volume mounted, and gave path to that folder for putting log file.
Used yaml file for creating container template so used in above mentioned way.
If you are using CLI to launch container, same can be passed through CLI too.

Protractor will not run with selenium grid

I want to use the protractor to run the tests on the selenium grid, which runs on :
http://<ip_address>:4444/
In my config file I have:
seleniumAddress: "http://32.14.98.73:4444/wd/hub",
When I run the test, they are run locally and start the browser on the local system. ? Anything else is needed for this to work ?
In logs I have:
[18:20:05] I/direct - Using ChromeDriver directly...
[18:20:05] I/launcher - Running 1 instances of WebDriver
Change your config file for object directConnect to directConnect:false. For detailed understanding on directConnect and seleniumAddress refer the below link Difference running Protractor with/without Selenium?

Web Driver Curl Exception

Trying to use Codeception Web Driver and Selenium to emulate ajax through an acceptance test. I was using PhpBrowser but when I was having issues with Ajax my friend suggested WebDriver.
After enabling it and downloading the selenium (and running it) I get the following error.
[WebDriverCurlException]
Curl error thrown for http POST to http://127.0.0.1:4444/wd/hub/session
with params: {"desiredCapabilities":{"browserName":"googlechrome"}}
Failed to connect to 127.0.0.1 port 4444: Connection Refused
I made sure I was running selenium on port 4444.
java -jar selenium-server.jar -port 4444
acceptance.suite.yml below
class_name: AcceptanceTester
modules:
enabled:
- WebDriver
- REST
config:
WebDriver:
url: 'http://life1605.dev'
browser: googlechrome
REST:
url: 'http://life1605.dev'
I had the same problem, with the exact same error message. For some strange reason, it looked like starting the selenium server from command line did not work.
My solution turned out to be manually opening the selenium server through Windows Explorer, right click on the file, choose Open with -> Java Platform SE Binary.
Took me almost 3 hours to figure it out, so I hope this helps somebody.
I had this problem and it turned out a new version of Firefox was incompatible with the addon that Selenium uses to communicate with Firefox.
When you start your tests you should see the new Firefox window appear, and have 30 seconds or so before it goes away again. Within this time, if you type about:addons into the URL field and then click on "Extensions", you should see the "Firefox WebDriver" addon there, and it should be enabled.
For me it was disabled as it was incompatible with the latest Firefox version. So the solution in this case was to either downgrade Firefox or wait for an updated Selenium.
Note that the addon is only installed in the Firefox instance under test, so you won't see it when you use Firefox outside of Selenium.
I had this same problem, I forgot to run phantom.js before trying to do any browser tests. I ran phantomjs and it worked.
I had this problem, and then I remembered that I need to run Xvfb -ac :0 -screen 0 1280x1024x16 & after every Homestead reload (before running Dusk tests).
Then Dusk works instead of saying:
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown
for http POST to /session with params:
{"desiredCapabilities":{"browserName":"chrome","platform":"ANY"}}
Operation timed out after 30000 milliseconds with 0 bytes received
See https://stackoverflow.com/a/42630737/470749

Running selenium test automatically

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

Selenium node failing to run IE or Chrome web drivers

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