Selenium grid to remote webdriver(chrome) hangs on get - selenium

I have a selenium grid with nodes on virtual machine. I can connect, open browser and close it but when i try navigating to a page it hangs on Executing: [get: http://google.com]
I use the latest verions of selenium, chromedriver and java.
Declaration:
DesiredCapabilities capabilities = DesiredCapabilities.Chrome();
driver = new RemoteWebDriver(new Uri(#"http://xxx.xx.xx.xxx:6000/wd/hub"), capabilities);
then i try to use it when i click a button on my win form:
driver.Navigate().GoToUrl("http://www.google.com");
I can see the node gets the command and logs Executing:[get:htttp://www.google.com] but just hangs. Url doesn't change in browser(its "data:," all the time )
I use windows 7 x64 and try to control browser on windows 7 x32. (if i connect to node on my pc the code works fine)
Any ideas?
Thanks!

I am seeing the exact issue with Safari (python). I am using selenium standalone server v2.47.1. My current workaround is to use JS:
"driver.execute_script("window.location.href = '{0}';".format(url))"
I also observed that if you don't set a homepage on Safari or have it default to load the homepage on new tab/window, the webdriver acts up and hangs on 'get' method.

Related

Google chrome closes automatically after launching using Selenium Webdriver

I am on Windows 10 using Selenium with Python 3.7.3.
If I wrap the code inside a class , the browser terminates immediately after opening the page:
'''
Program to show how to open chrome browser using selenium webdriver
'''
from selenium import webdriver
#import os
class run_chrome_tests(object):
def test_method(self):
# This is the location of the chrome driver saved into a variable
#driver_location = "D:\\Udemy_Python\\Libs\\chromedriver.exe"
# Letting the system environment know the location of the chrome driver
#os.environ["webdriver.chrome.driver"] = driver_location
# Letting the chrome browser know the location of the chrome driver
driver = webdriver.Chrome()
driver.get("http://www.letskodeit.com")
ch = run_chrome_tests()
ch.test_method()
Check the Version of the Chrome Browser and the Version of the chrome Driver , if the driver is not compatible then browser terminates just after opening,try using the latest version for both
By default, the chrome window will shutdown automatically, after it finishes all the instruments, unless you set the option to prevent this explicitly.
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option("detach", True)
driver = webdriver.Chrome(options=options)
driver.get("http://www.bing.com")
However, there is another possibility that you had chosen a WRONG version of chrome driver. The following is on how to select the right version of the chrome driver:
In the address bar of your chrome browser, type chrome://version. The first line of the returned page will be the version number.
Download one version of the chrome driver from this page. (https://chromedriver.storage.googleapis.com/index.html). Select the version that matches the version of your chrome as much as possible. (Very Important)

Detecting angularJS elements in IE11 browser using selenium takes long time. How to resolve this?

I'm running selenium tests on IE 11 in angularJS application. It takes more than usual time to detect/select/validate elements while it works better in chrome.
Browser information : Internet explorer 11
Webdriver : IEdriverserver 32bit
selenium version: 3.14
You could try the following methods to make it faster when using selenium IE WebDriver:
Download the recommended 32 bit Windows IE WebDriver version 3.150.1
and latest stable version 3.141.59 of Selenium from this page.
Change your IE settings: Tools -> Internet Options -> Security, set Enable Protected Mode to the same value in all zones (all checked or all unchecked).
Instantiate your InterExplorerWeDriver class with the path of your IE WebDriver like this:
InternetExplorerDriver ieDiver = new InternetExplorerDriver(“Path to the 32 bit IEdriver”);
Add capability nativeEvents as false. Add capability requireWindowFocus as true.
Reference link:
(1) Very slow text entry on IEDriverServer
(2) Selenium WebDriver typing very slow in text field on IE browser

Using Selenium on iPad?

I use a selenium application, and I make test on my computers browsers. It opens and manage the browsers.
Would there be a way to simulate an iPad and run this same code on it? Same thing for a cellphone?
So far I found people who wrote they did so by emulation but did not say how...
I execute iPad testing via emulation using ChromeDriver. Does this help? With C#:
IWebDriver driver;
ChromeOptions ipadOptions = new ChromeOptions();
string deviceName = "Apple iPad";
ipadOptions.EnableMobileEmulation(deviceName);
driver = new ChromeDriver(ipadOptions);
My biggest struggle was testing requirements depending on orientation (landscape vs. portrait.) It doesn't support switching orientation which is ridiculous.
To be able to use selenium code with Android device browser, try following:
install Android SDK on your computer to get access to Android Debug Bridge (adb) features
start adb server from cmd/Terminal with "adb start-server" command
(target device should be already connected)
start in the same way chromedriver server with "chromedriver" command (chromedriver executable should be already in your system Path)
you should see something like:
Starting ChromeDriver 2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3) on port 9515(in my case it always starts on 9515 port, but you have to check this value to use it in next step)
run code with 'androidPackage':com.android.chrome' chromeOptions and instance of remote webdriver. Python code looks like:
from selenium import webdriver
capabilities = {'chromeOptions': {'androidPackage':com.android.chrome',}}
driver = webdriver.Remote('http://localhost:9515', capabilities) # 9515 is mentioned port number on which chromedriver server started
driver.get('http://google.com')
driver.quit()
P.S. It's not a direct answer on question how to use selenium with iPad, but OP asks for selenium + Android also

Firefox 47.0 to crash on startup selenium webdriver

Yesterday we updated Firefox 47.0 and selenium test script started getting crash,
Please see attached screenshot.
Firefox getting crash
as mentioned in Firefox release notes they suggested to use Marionette WebDriver . We have downloaded Marionette WebDriver for windows and as mentioned in link we made code changes by adding Marionette WebDriver in bin/debug folder.Below are code changes for same
var driver = new FirefoxDriver(new FirefoxOptions());
However we are facing issue "entity not found"
Note : We are using c# selenium WebDriver on Windows7 64 bit OS and We tired below solution such as
Renamed Marionette WebDriver to wires.exe
Add Marionette WebDriver exe path in Environment variable.
Use RemoteWebDriver as shown below
DesiredCapabilities capabilities = DesiredCapabilities.Firefox();
// Set Marionette on so the Grid will use this instead of normal FirefoxDriver
capabilities.SetCapability("marionette", true);
var driver = new RemoteWebDriver(capabilities);
Please somebody help in this issue.
Have the same issue, the problem is unclear for now, but this kind of situation was before, you just need to wait new selenium update or Firefox fix (depends who introduced this problem), for now you could revert to previous version of FireFox.
https://support.mozilla.org/en-US/kb/install-older-version-of-firefox
UPD: Now if you using Firefox 47 you need to use new FirefoxDriver(geckodriver),
Details could be found here:
https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver
You need to add wires.exe to your System Path, not bin/debug. The Mozilla marionette instruction page does not mention bin/debug at all. Also make sure the executable is present on the path for the system your grid hub and grid nodes are running on, not just the system where the tests are running.

'Error on Page' while running Selenium script in IE8

I am trying to run Selenium Webdriver script in IE8 and soon as the page load is complete I am getting 'Error on Page', which eventually stops the execution of the script. Please note that if I launch the same URL manually, I don't see any error.
This is what I have tried so far
Unchecked Enable Protected Mode
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
driver = new InternetExplorerDriver(capabilities);
driver.get(AppURL);
driver.navigate().to("javascript:document.getElementById('overridelink').click()");
Nothing worked so far, however my script runs perfectly for FF and Chrome.
Please let me know if there is any possible solution to this issue, I am using Windows 7
This is expected. Selenium won't run properly unless you have the protected mode disabled in the internet explorer options.
Disable it and it should work fine.