I got a Jenkins windows 7 slave for testing my UI webapp using Selenium WebDriver (java, with Firefox and chrome drivers; machine is vmware vm).
Also, slave is connected to jenkins master using JNLP agent.
Problem is: Tests fail on slave, since resolution seems to be 800x600 whereas I need 1920x1080-ish.
Setting selenium web driver windows size won't do it, i.e.
driver.manage().window().setSize(new Dimension(1920, 1080));
driver.manage().window().maximize();
Any ideas? I'm trying to figure out where display resolution configuration should be done. Should it be done on JVM side (as test is execute by jenkins slave)? Or is it a windows issue?
We had a similar issue and we resolved it by setting up the Jenkins slave on windows an admin session of RDP started from a PC with a 1920x1080 resolution screen.
Start -> run -> mstsc /admin
This opens the Jenkins slave in the desired resolution.
Then, you just disconnect the RDP session and this leaves the session running in the desired resolution.
I hope this helps.
The display setup should be a one time activity performed on slave. You will have to remote into slave as admin using RDP to set resolution.
I had similar issue, then I used Phantom JS driver instead of Chrome
try this:
driver.manage().window().maximize();
driver.manage().window().setSize(new Dimension(1936, 1176));
Problem resolved from my end
Solution that worked for me is to run Chrome in a 'headless' mode (without GUI). It works with Jenkins Agent running as a service, when GUI is not available.
Here is the code sample of the web driver initialization (C#, I guess will be similar in java):
var options = new ChromeOptions();
options.BinaryLocation = #"C:\Program Files\Google\Chrome\Application\chrome.exe";
options.AddArgument("Headless");
options.AddArgument("window-size=1920,1080");
driver = new ChromeDriver(#"<path>\Selenium.WebDriver.ChromeDriver.2.37.0\driver\win32", options);
Related
I am having trouble in using headless chrome on jenkins remote server. the test is failed at the time of url invoking or takes to much of a time like 5+mins and test failed as it wont have waiting time for that long, i have tried different chromeoption like disable gpu, nosandbox etc still the issue is not solved.There is no issue in opening those url in normal mode but its not working on headless mode. i am using this chromeoptions for test:
enter code here
``` chromeOptions.addArguments("--window-size=1366,768");
chromeOptions.addArguments("--disable-gpu");
chromeOptions.addArguments("--disable-extensions");
chromeOptions.addArguments("--proxy-server='direct://'");
chromeOptions.addArguments("--proxy-bypass-list=*");
chromeOptions.addArguments("--start-maximized");
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("no-sandbox", "--disable-infobars", "--disable-dev-shm-usage", "--disable-browser-side-navigation",
"--ignore-certificate-errors");```
I have selenium based web application developed using spring boot. The server is located as VM Instance of google cloud server.
Please find below the details about the versions.
Spring Boot - 2.0.0.RELEASE
Selenium - 3.9.1
Linux - Debian 4.9.130-2 (2018-10-27) x86_64 GNU/Linux
Chrome Driver - 2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881)
Google Chrome - 70.0.3538.110
JDK - 1.8.0_232
From the past few days, I am facing a strange issue, application works fine when business hours start but after few hours it becomes unstable and whole application stop working, even user can not login.
After digging more for this issue I found the below error from server logs. I have to restart the VM Instance in order to fix it.
.
After restart, it works fine for a few hours and then we face same issue again.
Also, I have noticed that while sending an email we face the below issue which works fine before
a few minutes.
I also verified the server resource usage but didn't find any suspicious activity.
I googled for this issue but most of the solutions are provided for the problem being faced while running it first time. However, in my case it works fine for few hours and then start having this issue.
Please help me to understand the issue and root cause of this problem. It would be better if you can suggest a solution as well.
Thanks in advance.
This error message...
java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:1731
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.35
Release Notes of chromedriver=2.41 clearly mentions the following :
Supports Chrome v62-64
Presumably you are using chrome=70.0
Release Notes of ChromeDriver v2.44 clearly mentions the following :
Supports Chrome v69-71
Your Selenium Client version is 3.9.1 which is almost 2 years older.
So there is a clear mismatch between Selenium Client v3.9.1 , ChromeDriver v2.35 and the Chrome Browser v70.0
Solution
Ensure that:
Selenium is upgraded to current levels Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v79.0.3945.36 level.
Chrome is updated to current Chrome Version 79.0 level. (as per ChromeDriver v79.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 through Revo Uninstaller and install a recent GA and released version of Web Client.
Execute your #Test as non-root user.
In my case, it was bcoz of chrome driver instance was closed in the middle of test execution. so it was not able to get that particular chrome driver to process the selenium commands. I had to tweak the logic of chrome instantiation and closure as in my case, parallel 3 chrome instances were opened and these were getting closed in the middle of execution so the problem was not finding a particular needed chrome driver instance.
I have a problem with running my selenium test in headless mode with some specific profile (with extensions).
without headless, the script is working file (with specific profile), but with the headless mode, it is picking default profile which resulted in the failure of the script.
Tried some ways to solve this issue, but nothing worked.
chromeOptions.setAcceptInsecureCerts(true);
chromeOptions.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
chromeOptions.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
chromeOptions.addArguments("--remote-debugging-port=23456"); - this resulted in error at this port.
code setup for starting chrome browser in headless mode.
chromeOptions.setExperimentalOption("excludeSwitches",
Arrays.asList("disable-sync", "enable-logging"));
chromeOptions.addArguments("--enable-sync");
chromeOptions.addArguments("--disable-logging");
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--disable-dev-shm-usage");
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("--disable-gpu");
chromeOptions.addArguments("--window-size=1280,800");
chromeOptions.addArguments("--allow-insecure-localhost");
chromeOptions.addArguments("--remote-debugging-port=45447");
chromeOptions.setAcceptInsecureCerts(true);
chromeOptions.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
chromeOptions.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
Adding extensions are not supported with headless run.
So, used "Xvfb" virtual frame buffer to mock the chrome UI.
Remove "--headless" while starting the browser instance.
These are the steps that my code is running.
I start the chromedriver with the secure shell appt - no issues, it launches the browser and appt correctly
chromeOptions.addExtensions(new File("src/test/resources/win32/browserprofile/Secure-Shell-App_v0.8.43.crx"));
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
I then navigate using driver get to the chrome URL setup page to send connection data.
driver.get("chrome-extension://pnhechapfaindjhompbnflcldabbghjo/html/nassh.html");
While on this page from the image below, I tried to send keys or click on any of the fields with sendkeys or click and I get the following error.
I have tried multiple ways and im getting the same results: org.openqa.selenium.WebDriverException: unknown error: Cannot set property 'value' of null
Here is my code
//Webdriver
driver.findElement(By.xpath("//*[#id='field-description']")).sendKeys("aabb");
driver.findElement(By.id("field-username")).click();
driver.findElement(By.id("field-username")).sendKeys("useridval");
driver.findElement(By.id("field-hostname")).click();
driver.findElement(By.id("field-hostname")).sendKeys("10.0.0.0");
//JavascriptExecutor
// This will execute JavaScript in your script
((JavascriptExecutor)driver).executeScript("document.getElementById('field-username').value='migsrcrfuser';");
Question: Is this even possible, I see an id and the id is unique; furthermore, I also tried xpath and received the same result. Thoughts
Breift description: Terminal emulator and SSH client.
Secure Shell is an xterm-compatible terminal emulator and stand-alone ssh client for Chrome. It uses Native-Client to connect directly to ssh servers without the need for external proxies.
https://chrome.google.com/webstore/detail/secure-shell-extension/iodihamcpbpeioajjeobimgagajmlibd
Update your ChromeDriver to 2.37 (the latest) from https://sites.google.com/a/chromium.org/chromedriver/downloads
I think that you are using Chrome v65
The issue was frame related. I used this code to identified how many frames and then send keys to the correct frame. phew!
int size = driver.findElements(By.tagName("iframe")).size();
System.out.println(size);
driver.switchTo().frame(1); // Switching the inner Frame with 1 0 for outer fram
driver.findElement(By.xpath("//*[#id='field-description']")).sendKeys("9109");
Internet Explorer - version 9
Selenium - 2.42.2
language - JAVA
What steps will reproduce the problem?
1.Trigger a login test on windows VM on IE with the following capabalities:
InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS=true
InternetExplorerDriver.IGNORE_ZOOM_SETTING=true
InternetExplorerDriver.REQUIRE_WINDOW_FOCUS=true
InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING=true
InternetExplorerDriver.NATIVE_EVENTS=false
InternetExplorerDriver.INITIAL_BROWSER_URL="https://***********.com
2.Minimise the VM and
3.Wait for the selenium script to run and then maximise the VM to check if the tests are running fine.
What is the expected output? What do you see instead?
Expected Output: The login to the application should be completed.
Instead, the test is stuck in the login page. The user-id and password is not entered.(The webdriver is unable to identify the element)
Selenium version:2.42.2
OS:Windows 7
Browser:Internet Explorer
Browser version:9
The tests are triggered from jenkins server remotely. The tests run fine when it is in the foreground, but fails if the VM or IE is minimised.
If you are able to change the Protected Mode settings for each zone to same value (details are here). Then don't set following capability -
InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS=true
And also try without setting following capabilities (make sure zoom level set to 100%) -
InternetExplorerDriver.IGNORE_ZOOM_SETTING=true
InternetExplorerDriver.REQUIRE_WINDOW_FOCUS=true