I'm using Selenium Grid to run some automated tests that always worked locally. I've created a RemoteWebDriver object, and used remoteDriver.setFileDetector(new LocalFileDetector()) to activate the local file detector. All of the pages I can find list this as the only solution, as if nothing can possibly go wrong with it.
In summary, selenium is definitely uploading the files from my local Windows filesystem, to Selenium Grid running on Linux. GeckoDriver can find it just fine, but ChromeDriver says it's not found:
invalid argument: File not found : /tmp/41dd2016f9974950127c20f7d25df461/upload7388365119198958794file/hasThemesWithImages.zip
(Session info: headless chrome=109.0.5414.74)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'PAX-314945', ip: '192.168.50.241', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.16.1'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 109.0.5414.74, chrome: {chromedriverVersion: 109.0.5414.74 (e7c5703604da..., userDataDir: /tmp/.org.chromium.Chromium...}, goog:chromeOptions: {debuggerAddress: localhost:39795}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true, webdriver.remote.sessionid: 41dd2016f9974950127c20f7d25...}
Session ID: 41dd2016f9974950127c20f7d25df461
If I ssh to the remote host while it's still running, and type ls -l and paste in that long pathname, then I see the file is present. It's the correct size, and has global read permissions. I can even examine the zip contents. And yet, chromedriver gives the error above.
I started the grid server with a very simple java -jar selenium-server-standalone-3.141.59.jar command, with no other options, and am using Chromium in headless mode.
I have tried starting Chromium with and without --no-sandbox and --disable-dev-shm-usage as command line options.
I'm using Geb 3.4.1 and Groovy 2.x on the client side, and it looks like I'm doing everything correctly. I tried a few different tests that worked locally before, and added some logging in the test to confirm that driver.getFileDetector() returned the LocalFileDetector instance. Here is the relevant portion of my GebConfig.groovy file:
def remoteWebDriver(Capabilities capabilities) {
URL hubUrl = new URL("http://192.168.1.5:4444/wd/hub")
new RemoteWebDriver(hubUrl, capabilities)
}
FirefoxProfile myFirefoxProfile() {
// omitted; I hope it's not important.
}
environments {
gridFirefox { // file uploads work
driver = {
println "creating a RemoteDriver"
FirefoxOptions opts = new FirefoxOptions()
opts.addArguments("--headless")
opts.profile = myFirefoxProfile()
RemoteWebDriver remoteDriver = remoteWebDriver(opts)
remoteDriver.setFileDetector(new LocalFileDetector())
remoteDriver
}
}
gridChrome { // file uploads don't work
driver = {
println "creating a Chrome RemoteDriver"
ChromeOptions chrome_options = new ChromeOptions()
chrome_options.addArguments("--window-size=1600,1100")
chrome_options.addArguments('--headless')
//chrome_options.addArguments('--no-sandbox')
//chrome_options.addArguments('--disable-dev-shm-usage')
RemoteWebDriver remoteDriver = remoteWebDriver(chrome_options)
remoteDriver.setFileDetector(new LocalFileDetector())
remoteDriver
}
}
}
Related
Selenoid version - 1.10.0
Chrome version - 85.0
Docker image - selenoid/vnc_chrome:81.0
Exception -
org.openqa.selenium.WebDriverException: unknown error: unhandled inspector error: {"code":-32000,"message":"Object reference chain is too long"}
(Session info: chrome=80.0.3987.87)
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'mani-zt254', ip: 'fe80:0:0:0:4b9:53da:b2d:19d3%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 80.0.3987.87, chrome: {chromedriverVersion: 80.0.3987.16 (320f6526c1632..., userDataDir: /tmp/.com.google.Chrome.g10u57}, goog:chromeOptions: {debuggerAddress: localhost:45089}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: accept}
Session ID: 53b76f85512a10c9c08655240eef4042
Scenario
The above exception occurs while finding an element/performing any operation using jquery 1.x versions
So I inject the latest jQuery 3.5.0 able to perform the actions using jquery but some pages some jquery methods conflict occur due to this some errors occur in browser console click is not working in some elements, the above problems are there chrome 80.0 and above versions, now I'm using chrome 85.0.
Probably instead of calling:
evaluate_script
You should call:
execute_script
To elaborate. There is not so much information in the question itself, but in the feature test, if you are calling a script to be executred, you should call it with execute_script and not with evaluate_script
But there is not so much information in the question form a year or so, so just giving a wild quess.
Why this error TypeError: rootNode is null happens when taking screenshots? Is there a problem in HTML DOM structure which the developer should fix or is it a problem with Selenium version?
This error is happening when taking screenshot:
org.openqa.selenium.WebDriverException: TypeError: rootNode is null
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'linuxhost', ip: 'x.x.x.x', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-754.17.1.el6.x86_64', java.version: '1.8.0_202'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 60.8.0, javascriptEnabled: true, moz:accessibilityChecks: false, moz:headless: false, moz:processID: 6651, moz:profile: /tmp/rust_mozprofile.LlBKoU..., moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, platformVersion: 2.6.32-754.17.1.el6.x86_64, rotatable: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}}
Session ID: 1afd06ed-4939-42c9-9d1d-51fa113dfe97
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:609)
at org.openqa.selenium.remote.RemoteWebDriver.getScreenshotAs(RemoteWebDriver.java:295)
dependency version:
Firefox: Mozilla Firefox 60.8.0
geckodriver: 0.23.0
selenium: 3.141.59
geb-spock:3.0.1
I just tried and it worked for me.
Firefox : 69.0 (64-bit)
Gecko Driver: v0.25.0
Webdriver: 3.141.59
FirefoxDriver fdriver;
System.setProperty("webdriver.gecko.driver", "/path/geckodriver");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
FirefoxOptions foptions = new FirefoxOptions();
foptions.merge(capabilities);
fdriver = new FirefoxDriver(foptions);
fdriver.get("http://demo.guru99.com/selenium/guru99home/");
File src = ((TakesScreenshot) fdriver).getScreenshotAs(OutputType.FILE);
try {
// now copy the screenshot to desired location using copyFile //method
FileUtils.copyFile(src, new File("path/fchart.png"));
fdriver.quit();
}
catch (IOException e) {
System.out.println(e.getMessage());
}
I found out why "TypeError: rootNode is null" error is happening.
This error happens if test is trying to taking screenshot before even the html page source is completely downloaded.
Adding a dynamic wait to wait for page to load completely did fixed this issue.
waitFor {
((JavascriptExecutor)driver).executeScript("return document.readyState").equals("complete")
}
takeScreenshot()
When setting the window size for chrome to either maximized or 1980x1080 using
ChromeOptions.addArguments("--start-maximized");
or
driver.manage().window().setSize(new Dimension(1980,1080));
or
ChromeOptions.addArguments("window-size=1980,1080");
or
ChromeOptions.addArguments("--window-size=1980,1080");
the Chrome window is set to the correct size and works perfectly when running the tests from either the terminal or running individual test cases from intellij (all tests Pass)
However, when my GOCD pipeline picks up the job, everything starts working (tests start executing normally) then in the log I see that the window being used in the test has a size of 1044 x 788.
This causes an issue as a button I need is on the far right and out of the field of view due to the size of the screen (I assume)
message received is
2018-11-28 13:38:52.542 WARN 4456 --- [ main] utils.PageUtils : element not interactable
(Session info: chrome=70.0.3538.110)
(Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:25:02.294Z'
System info: host: 'DEV', ip: '192.168.1.177', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.44.609538 (b655c5a60b0b54..., userDataDir: C:\windows\TEMP\scoped_dir1...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:62401}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 70.0.3538.110, webStorageEnabled: true}
Session ID: e3f442486d9087e190e0954c5fcc19f5: Click(btnSearchDropMenu) failed! re trying...
2018-11-28 13:38:52.549 WARN 4456 --- [ main] utils.PageUtils : Screen dimentions: (1044, 788)
2018-11-28 13:38:52.550 INFO 4456 --- [ main] utils.PageUtils : Scrolling to move 'btnSearchDropMenu' to the middle of the screen
2018-11-28 13:38:53.619 ERROR 4456 --- [ main] BaseTestFolder.BaseTest : org.openqa.selenium.ElementNotVisibleException: element not interactable
(Session info: chrome=70.0.3538.110)
(Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
I have tried passing the set size command in different areas including just before trying to click the button that's missing and re ordered when options are passed to my chrome options object before they are passed to the chrome driver.
I need the window to be at least 1980x1080 but i'm unsure why this is not able to be set when the tests run on the GOCD
I'm at a loss as to why this issue is occurring. any help would be greatly appreciated
**EDIT 1 **
What is strange is that I can reduce the window size and this property will keep...
2018-11-28 15:47:02.754 INFO 19088 --- [ main] configuration.GoogleChrome : Window size: (1000, 600)
EDIT 2
Added another argument i tried,
This is also an issue with jenkins- defaults to the same Window size: (1044, 788)
This issue looks to have been caused by two issues,
1- When mvn clean test is run from the IDE this process runs under your current user. However, when run by the CI environment, the process is owned by the CI process. so does not have the same access to resources.
2 When run from the IDE, chrome will pop up. When run from the CI environment I assumed that it defaulted chrome to run in headless mode. It does not, you have to set the --headless argument so my configuration that now works is as follows
public class GoogleChrome extends Base {
private static final Logger logger = LogManager.getLogger(GoogleChrome.class);
private String rootPath = System.getProperty("user.dir").replace("\\","/");
#Autowired
protected WebDriver driver;
public WebDriver startChromeDriver() {
logger.info("Chrome driver path : " + rootPath + "/../Tools/Drivers/chromedriver.exe");
System.setProperty("webdriver.chrome.driver", rootPath + "/../Tools/Drivers/chromedriver.exe");
Map<String, Object> prefs = new HashMap<String, Object>();
logger.info("Disabling Chrome's credentials service");
prefs.put("credentials_enable_service", false);
logger.info("Disabling Chrome's password manager");
prefs.put("password_manager_enabled", false);
final String regex = "^\\D*$";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(System.getProperty("user.name"));
boolean isHuman = matcher.matches();
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
logger.info("Disabling Chrome's info bars");
options.addArguments("disable-infobars");
options.addArguments("--incognito");
options.addArguments("--disable-gpu");
options.addArguments("--no-sandbox");
options.addArguments("--allow-insecure-localhost");
if (isHuman){
logger.info("Chrome starting maximized - isHuman: " +isHuman + " process run by " +System.getProperty("user.name"));
options.addArguments("--start-maximized");
} else {
logger.info("Chrome starting headless - isHuman: " +isHuman + " process run by " +System.getProperty("user.name")) ;
options.addArguments("--headless");
options.addArguments("--window-size=1980,1080");
}
options.setAcceptInsecureCerts(true);
try {
logger.info("Killing Chrome browser");
Runtime.getRuntime().exec("taskkill /F /IM chrome.exe");
} catch (IOException e) {
logger.error("Task Kill IOException : " + e.getMessage());
}
logger.info("Starting Chrome browser...");
sleep(2);
driver = new ChromeDriver(options);
logger.info("Window size: "+ driver.manage().window().getSize());
driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
return driver;
}
}
I am trying to use Browsermob proxy for achieving the basic http authentication across different browsers. But facing issues, tried to search for a solution on Browsermob's GITHUB page but didn't find much help there.
Here is my code for the achieving the auth:
// start the proxy
BrowserMobProxy proxy = new BrowserMobProxyServer();
proxy.start();
proxy.autoAuthorization("", "username", "password", AuthType.BASIC);
// get the Selenium proxy object
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
// configure it as a desired capability
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
If I run above code on chrome then it still asks for auth. And nothing appears in the error console.
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + config.getChromeDriverPath());
WebDriver driver = new ChromeDriver(capabilities);
If I run above code on firefox then it gives error
Your connection is not secure.
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + config.getChromeDriverPath());
WebDriver driver = new ChromeDriver(capabilities);
And in the console following error appears:
FAILED CONFIGURATION: #BeforeClass launchBrowser
org.openqa.selenium.WebDriverException:
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: 'USER', ip: '192.168.43.57', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_161'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: false, browserName: firefox, browserVersion: 60.0.2, javascriptEnabled: true, moz:accessibilityChecks: false, moz:headless: false, moz:processID: 8180, moz:profile: C:\Users\USER\AppDat..., moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: XP, platformName: XP, platformVersion: 6.3, proxy: Proxy(manual, http=tarun:49..., rotatable: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}}
Session ID: 6b53fdb7-78fe-44cb-a3b9-2592494ae7a5
What is not correct?
proxy.autoAuthorization("", "guest", "guest", AuthType.BASIC);
this feature does not work.
Use this instead:
String encodedCreadentials = "Basic " + (Base64.getEncoder().encodeToString("login:password".getBytes()));
proxy.addHeader("Authorization", encodedCreadentials);
I am trying to run protractor e2e tests on IE11. tests are failing with timeout error.
[Test Error Output]
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
[19:03:47]
[should not allow Clifton to create a sub-folder inside a folder previously created by Emmett] Failed: JavaScript error in async script. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.29 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: '', ip: '10.50.10.158', os.name: 'Windows Server 2008 R2', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_79'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{platform=WINDOWS, javascriptEnabled=true, elementScrollBehavior=1, ignoreZoomSetting=false, enablePersistentHover=false, ie.ensureCleanSession=false, browserName=internet explorer, enableElementCacheCleanup=true, ie.enableFullPageScreenshot=true, unexpectedAlertBehaviour=dismiss, ie.fileUploadDialogTimeout=3000, ie.forceShellWindowsApi=false, version=11, pageLoadStrategy=normal, ignoreProtectedModeSettings=false, requireWindowFocus=true, initialBrowserUrl=http://localhost:48570/, ie.forceCreateProcessApi=false, nativeEvents=true, browserAttachTimeout=0, ie.browserCommandLineSwitches=}]
I tried below this as mentioned in different blogs or post /issue links
Increase the test case time out from protractor e2e configuration.
Updating the protractor and selenium IE driver version.
Adding IE specific configuration setting in e2e configuration. e.g
capabilities: {
elementScrollBehavior: 1,
browserName: 'chrome',
// IE specific, enables modifier keys (eg. CTRL+CLICK)
requireWindowFocus: true,
// If this is set to be true, specs will be sharded by file (i.e. all
// files to be run by this set of capabilities will run in parallel).
// Default is false.
shardTestFiles: false,
// Maximum number of browser instances that can run in parallel for this
// set of capabilities. This is only needed if shardTestFiles is true.
// Default is 1.
maxInstances: 1,
loggingPrefs: {
//this is a chrome specific setting - no effect on other browser runs
performance: "OFF"
},
nativeEvents: false,
unexpectedAlertBehaviour: 'accept',
ignoreProtectedModeSettings: true,
enablePersistentHover: true,
requireWindowFocus: true,
ignoreZoomSetting: true,
INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS: true
}
Configuring the IE browser settings as recommended in the below link http://elgalu.github.io/2014/run-protractor-against-internet-explorer-vm/#
Protractor test in IE
Using browser.driver.get() instead of browser.get() as mentioned in link: https://github.com/angular/protractor/issues/4268
Is their any limitations running protractor e2e tests on IE11 ?