Firefox Webdriver is extremely slow - selenium

We use the selenium webdriver dlls set up to run my automation suite. I encounter this problem when runnning tests in Firefox only. The tests in Firefox run very slow , taking 3-4 minutes to load pages, However, when I run the same test on the same machine using Firefox browser manually I don't encounter this slowness. At times while running automation on Firefox, we also get "Connection was reset" page. Also, the same tests run fine in Chrome and IE.
We use the following environment:
Firefox version 28, 37 (proxy is set to use system settings)
Webdriver (dlls) version 2.45
Windows 7
Earlier we used to run the same set up in Windows XP using Firefox version 14,16, and Webdriver version 2.37, we didn't experience this issue.
We invoke Firefox using the following code :
Proxy proxy = new Proxy();
proxy.Kind = ProxyKind.System;
FirefoxProfile profile = new FirefoxProfile();
profile.SetProxyPreferences(proxy);
RemoteWebDriver dr = new FirefoxDriver(new FirefoxBinary(#"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"), profile, TimeSpan.FromSeconds(120));
dr.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));
dr.Manage().Window.Maximize();
dr.Manage().Cookies.DeleteAllCookies();
dr.Navigate().GoToUrl(WebSiteUrl);
remaining tests steps......
Please can someone help me resolve this issue.
Thanks in advance.

This is how I solved the "extremely slow FirefoxDriver" problem:
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService();
service.Host = "::1";
IWebDriver driver = new FirefoxDriver(service);
The above code forces the geckodriver to use the IPv6 protocol, which works many times faster for the interactions with the UI elements.

Probably won't do you any good now, but I had the same problem with Firefox 45 and Webdriver 2.15. Turned the problem was the implicit wait setup. In my case, I had:
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
This one line was taking 190 seconds (yes, more than 3 minutes!) to execute. Removing it cut the startup time to under 8 seconds!

Related

Blank page on headless Selenium tests run with Jenkins

Headless Selenium tests can be well run on my machine (yup, I should definitely move in this ideal place where problems doesn't exist).
However, when I launch those tests via Jenkins, none of the page elements are found. I took a screenshot to figure out why, and it shows a blank page.
This is how I instanciate my headless Chrome browser.
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NONE);
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("--window-size=1920x1080");
chromeOptions.addArguments("start-maximised");
chromeOptions.addArguments("enable-automation");
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--disable-infobars");
chromeOptions.addArguments("--disable-dev-shm-usage");
chromeOptions.addArguments("--disable-browser-side-navigation");
chromeOptions.addArguments("--disable-gpu");
driver = new ChromeDriver(chromeOptions);
driver.manage().timeouts().pageLoadTimeout(30L, TimeUnit.SECONDS);
driver.manage().timeouts().setScriptTimeout(3L, TimeUnit.SECONDS);
driver.manage().window().maximize();
I have a guess but my coworker says it can't be this: should I install Xvfb on Jenkins server? I mean, is it mandatory? (I must be at least 51% sure before trying this approach ^^)
Thanks in advance.
I tried lots of solutions but it turned out that Jenkins wasn't allowed to access the resources I needed to test. So... I couldn't solve it myself anyway. Sysadmins did.

Getting Timed out receiving message from renderer: 600.000 When we execute selenium scripts using Jenkins windows service mode

We are executing our selenium automation script using jenkins window service(Headless mode) on daily basis .it was working fine till yesterday. suddenly it stopped working and not launching the browser. it shows the below error message [1553677874.187][SEVERE]: Timed out receiving message from renderer: 600.000. after that all the remaining test cases are getting failed.
It is working fine if we run the build using jenkins as without windows service. We are experiencing this issue only with windows as service
My chrome driver version :73.0.3683.68
Chrome browser version :73.0.3683.68
Selenium Version :3.14.0
I have tried to downgrade the browser version and driver version. even though it is not working
I am expecting the browser should launch in the background when we execute using jenkins as windows service but getting error message.
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("load-extension=C:\\1.13.4_0");
options.addArguments("--start-maximized");
options.addArguments("--ignore-certificate-errors");
options.addArguments("--disable-popup-blocking");
// options.addArguments("window-size=1400,600");
options.addArguments("enable-automation");
options.addArguments("--headless");
options.addArguments("--window-size=1920,1080");
options.addArguments("--no-sandbox");
// options.addArguments("--disable-extensions");
options.addArguments("--dns-prefetch-disable");
options.addArguments("--disable-gpu");
options.setPageLoadStrategy(PageLoadStrategy.NORMAL);
DesiredCapabilities capabilities =
DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY,
**strong text**options);
return new ChromeDriver(capabilities);
Seems you are using the following configuration:
chromedriver=73.0.3683.68
chrome=73.0.3683.68
Windows OS
John Chen (Owner - chromedriver) recently have confirmed that,
We have confirmed issues with take screenshot when Chrome 73.0.3686.75 is started by a service (such as Jenkins or Task scheduler) on Windows. Please see https://crbug.com/942023 for more details. We apologize for any inconvenience caused by this. However, we haven't yet been able to observe similar issue on Linux, so we appreciate any help you can provide to enable us to reproduce the issue on Linux. We don't have access to TeamCity, but we have tested take screenshot using Docker image produced by Selenium (selenium/standalone-chrome:3.141.59-lithium), and didn't find any problems.
Yesterday (Mar 26, 2019), John once again confirmed:
I am aware of some issues with running Chrome 73 from Jenkins. I don't know any workarounds. Please following https://crbug.com/942023 for updates.
Update
We were able to dig up the main issue. The main issue is not with ChromeDriver v73.x as such but with Chrome v73.x and John officially confirms it as:
The root cause is indeed in Chrome 73.x, not in ChromeDriver. We are working with Chrome devs to find a solution.
Solution
A quick fix solution will be to:
Downgrade Chrome Browser to Chrome v72.x
Use a matching ChromeDriver among:
ChromeDriver 2.46
ChromeDriver 72.0.3626.69
Note: If you are using Chrome version 72, please download ChromeDriver 2.46 or ChromeDriver 72.0.3626.69
Ensure that JDK is upgraded to recent level of JDK 8u202.
Outro
You can find the relevant discussions in:
Page.captureScreenshot no longer works in Chrome 73 under Selenium as a Service on Windows
Error [SEVERE]: Timed out receiving message from renderer: 20.000 while executing the testsuite through Selenium on Jenkins
Download Google Chrome 72 Offline Installer For All Operating Systems
Update(03-April-2019)
Adding the argument --disable-features=VizDisplayCompositor through an instance of ChromeOptions() seems solves the issue:
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-features=VizDisplayCompositor");
WebDriver driver = new ChromeDriver(options);
driver.get("https://google.com");
Possible problem is that your Google Chrome updated and became incompatible with your Chromedriver. I suggest either getting a new Chromedriver or downgrading your Google Chrome to a previous version and disabling auto updates.
You can verify the required Chromedriver version for your Google Chrome here:
http://chromedriver.chromium.org/downloads
Step 4 of the following link worked for me to disable automatic google Chrome updates.
https://www.webnots.com/7-ways-to-disable-automatic-chrome-update-in-windows-and-mac/
Add below property(1) before ChromeDriver initialization
System.setProperty("webdriver.chrome.silentOutput", "true");
driver = new ChromeDriver();

Running Selenium via jenkins on VM, screen size

I have a problem with running Selenium tests on VM.
Tests are written under 1920x1080 resolution everything is OK until I run tests manually. Tests passes. The problem appear when I run tests through Jenkins. It's not a problem in my code.
I dont know why but screen resolution is much lower (1032, 776) - actually it's browser size. And that is the cause why buttons to test are not visible. Tests fails.
Jenkins is opening by "Run slave agent via Java Web Start" and evertyhing works automatically on windows serwer. Old Selenium tests (written under lower resolution) works perfect. So the problem is closely related to screen size.
Thank you in advance.
If you are working on Windows the following should work:
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless");
options.addArguments("--window-size=1920,1080");
System.setProperty("webdriver.chrome.driver","\\path\\chromedriver.exe");
driver = new ChromeDriver(options);

Selenium IE Webdriver send slowkeys even though changed to 32Bit

I have a serious Problem, and i tried about 20 workarounds which completely failed to work as a solution for me.
MainProblem: I execute a testsuite parallel on 3 different browsers, Chrome, Firefox and IE11. While sendKeys() works perfectly fine on chrome and Firefox, on IE every letter takes about 5 seconds to appear, so a normal login-procedure which takes about 2 sec on chrome takes about 50 on IE...
I work on a mac. On the Mac, i have a WindowsPC (Win10) in a VM via Parallels. On this, i installed JDK, Eclipse, and try to automate a webpage via Selenium+Testng.
IE Version: 11.192.16299.0
I set the security level to low for trusted and local intranet, i removed the save-mode checkbox. I got the well known slow-sendKeys-Problem. But for most of the internet it worked with changing the IEWebdriver from 64-> 32Bit. It simply doesnt make any difference and i struggle here.
I really need help. Please let me know if you need any insight, logs or whatever, i try to provide with everything fast.
Best Greets!
By setting up the following options It should resolve the problem:
System.setProperty("webdriver.ie.driver", "./path/IEDriverServer.exe");
InternetExplorerOptions options = new InternetExplorerOptions();
options.introduceFlakinessByIgnoringSecurityDomains();
options.requireWindowFocus();
WebDriver driver = new InternetExplorerDriver(options);

HtmlUnitDriver fails to load url.

I am currently using HtmlUnitDriver 2.45 version and when I run below code snippet
BrowserVersion version = BrowserVersion.CHROME;
WebDriver driver = new HtmlUnitDriver(version);
driver.get("http://www.google.com");
System.out.println(driver.getCurrentUrl());
my output is "about:blank".
I have noticed that driver instance created from default constructor
WebDriver driver = new HtmlUnitDriver(true);
creates driver object with deprecated default browser version "INTERNET_EXPLORER_8"
/** The default browser version. */
private static BrowserVersion DefaultBrowserVersion_ = INTERNET_EXPLORER_8;
Am I missing something while creating HtmlUnitDriver??
My experience with HTMLUnitDriver has been pretty terrible so far. It doesn't really serve as a viable testing driver due to the multiple compatibility issues it has with different applications (depends on the application).
If you are trying to do headless browser testing, I would suggest running PhantomJSDriver rather than HTMLUnitDriver. In your use-case this should be fine, since you are trying to run HTMLUnitDriver as the CHROME browser version, and PhantomJS is webkit-based.