Selenium Grid UnreachableBrowserException - selenium

org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-37JVVAA', ip: '199.254.9.005', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: driver.version: Driver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:573)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:144)
at automationFramework.Driver.startWebDriver(Driver.java:80)
Caused by: java.io.IOException: unexpected end of stream on Connection{grid-selenium-hub.es-selenium-use.us-east-1.acceptance.com:4444, proxy=DIRECT hostAddress=grid-selenium-hub.es-selenium-use.us-east-1.acceptance.com/12.55.42.001:4444 cipherSuite=none protocol=http/1.1}
at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:208)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
{
"browserTimeout": 0,
"capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"cleanUpCycle": 5000,
"custom": {
},
"debug": false,
"host": "90.395.99.144",
"jettyMaxThreads": -1,
"newSessionRequestCount": 0,
"newSessionWaitTimeout": -1,
"port": 4444,
"registry": "org.openqa.grid.internal.DefaultGridRegistry",
"role": "hub",
"servlets": [
],
"slotCounts": {
"free": 10,
"total": 10
},
"success": true,
"throwOnCapabilityNotPresent": true,
"timeout": 1800,
"withoutServlets": [
]
}
Node has following:
browserTimeout: 0
debug: false
jettyMaxThreads: -1
host: 90.115.91.25:5555
port: 5555
role: node
timeout: 1800
cleanUpCycle: 5000
maxSession: 1
capabilities: Capabilities {applicationName: , browserName: chrome, maxInstances: 1, platform: LINUX, platformName: LINUX, seleniumProtocol: WebDriver, server:CONFIG_UUID: 277ded26-3931-42ec-b9e6-a6b..., version: 79.0.3945.117}
downPollingLimit: 2
hub: http://selenium-grid-selenium-hub:4444/grid/register
id: http://90.115.91.25:5555
nodePolling: 5000
nodeStatusCheckTimeout: 5000
proxy: org.openqa.grid.selenium.proxy.DefaultRemoteProxy
register: true
registerCycle: 5000
remoteHost: http://90.115.91.25:5555
unregisterIfStillDownAfter: 60000
Driver has following code
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
options.addArguments("--disable-infobars");
options.addArguments("--disable-extensions");
options.addArguments("chrome.switches", "--disable-extensions");
options.addArguments("--disable-gpu");
options.addArguments("--disable-dev-shm-usage");
options.addArguments("--no-sandbox");
options.addArguments("--disable-notifications");
options.addArguments("--disable-popup-blocking");
options.addArguments("enable-automation");
options.addArguments("--disable-dev-shm-usage");
options.addArguments("--disable-browser-side-navigation");
options.addArguments("--dns-prefetch-disable");
options.setExperimentalOption("useAutomationExtension", false);
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
world.driver = new RemoteWebDriver(new URL(AWS_URL), options);
world.driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);
We recently created grid on aws and see this issue for some of the pods(which is working fine earlier), though its same hub URL for all

Related

Selenium Grid Driver.Version Unknown

I know that this question is asked many times and the answers helped me once.
I used to start as an experiment a Selenium Grid Hub on my local machine and an Node on an other machine. Both were started using parameters on the command line. I was able to start a test so the configuration worked.
Since I do not want to run the hub on my local machine I started is on the same machine as the node but now using JSON config files.
Now I get the WebDriverException: Error forwarding the new session cannot find ... giving the driver.version: unknown error.
I am sure that I pass the version so the error leaves me puzzled.
The node is according to the hub's out put correctly registered. The nodeconfig JSON is:
{
"capabilities":
[
{
"browserName": "chrome",
"maxInstances": 5,
"seleniumProtocol": "WebDriver",
"version": 93,
"platform": "WIN10"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 5,
"port": 5555,
"register": true,
"registerCycle": 5000,
"hub": "http://localhost:4444",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets" : [],
"withoutServlets": [],
"custom": {}
}
The console output in Eclipse shows this error description:
Caused by: org.openqa.selenium.WebDriverException: Error forwarding the new session cannot find : Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless, --window-size=1920,955, --ignore-certificate-errors, --disable-gpu], extensions: []}, platform: WIN10, version: 93}
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'XXXXXXXXXX', ip: 'ipx.xxx.xxx.xxx', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_302'
Driver info: driver.version: unknown
The hub show following:
ipy.yyy.yyy.yyy INFO [RequestHandler.process] - Got a request to create a new session: Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless, --window-size=1920,955, --ignore-certificate-errors, --disable-gpu], extensions: []}, platform: WIN10, version: 93}
ipy.yyy.yyy.yyy INFO [RequestHandler.process] - Error forwarding the new session cannot find : Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless, --window-size=1920,955, --ignore-certificate-errors, --disable-gpu], extensions: []}, platform: WIN10, version: 93}
org.openqa.grid.common.exception.CapabilityNotPresentOnTheGridException: cannot find : Capabilities {browserName: chrome, goog:chromeOptions: {args: [--headless, --window-size=1920,955, --ignore-certificate-errors, --disable-gpu], extensions: []}, platform: WIN10, version: 93}
The Chrome version on the node is 93.0.4577.82. Do I need to spell this out?
Can anyone give me a clue how to solve this?
All examples on the net are showing version numbers like 93.0 or 93 .
So yes, I had to spell it out like 93.0.4577.82

Protractor tests randomly fails in IE 11 on wait for ExpectedCondition.presenceOf()

I am writing ui tests for non angular app and run protractor in IE11 and it randomly fails on
await browser.wait(protractor.ExpectedConditions.presenceOf(element(by.name('TOBACO_SCANNED_SERIAL'))),
5000,
"serial number input must be present");
It's not event fails after wait, it just fails on this code immediately.
I'm using InternetExplorerDriver 32-bit version 3.4.0 and protractor 5.4.2.
Here's full stacktrace for error
Stack:
JavascriptError: (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 254 milliseconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'CICD', ip: '192.168.0.4', os.name: 'Windows Server 2016', os.arch: 'x86', os.version: '10.0',
java.version: '1.8.0_231'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{se:ieOptions={browserAttachTimeout=0.0, ie.enableFullPageScreenshot=true, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.forceShellWindowsApi=false, ignoreZoomSetting=true, ie.fileUploadDialogTimeout=3000.0, ie.useLegacyFileUploadDialogHandling=false, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0.0, ie.browserCommandLineSwitches=, requireWindowFocus=false, initialBrowserUrl=http://localhost:48605/, ignoreProtectedModeSettings=true, enableElementCacheCleanup=true}, browserName=internet explorer, pageLoadStrategy=normal, javascriptEnabled=true,
version=11, platform=WINDOWS, unexpectedAlertBehaviour=accept}]
Session ID: 197d9a98-25c5-4ab1-882f-e9c1ec8aa3e1
*** Element info: {Using=css selector, value=*[name="TOBACO_SCANNED_SERIAL"]}
at Object.checkLegacyResponse (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\http.js:509:13)
at C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\http.js:441:30
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
From: Task: WebDriver.findElements(By(css selector, *[name="TOBACO_SCANNED_SERIAL"]))
at thenableWebDriverProxy.schedule (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\webdriver.js:807:17)
at thenableWebDriverProxy.findElements (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\webdriver.js:1048:19)
at C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\protractor\built\element.js:159:44
at ManagedPromise.invokeCallback_ (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:1376:14)
at TaskQueue.execute_ (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:2927:27
at C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:668:7
From: Task: <anonymous>
at pollCondition (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:2195:19)
at C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:2191:7
at new ManagedPromise (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:1077:7)
at ControlFlow.promise (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:2505:12)
at C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:2190:22
at TaskQueue.execute_ (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:2974:25
at C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:668:7
From: Task: serial number input must be present
at scheduleWait (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:2188:20)
at ControlFlow.wait (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:2517:12)
at thenableWebDriverProxy.wait (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\webdriver.js:934:29)
at run (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\protractor\built\browser.js:59:33)
at ProtractorBrowser.to.<computed> [as wait] (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\protractor\built\browser.js:67:16)
at SerialNumbersPage.<anonymous> (C:\Users\EBiriukov\Programm\bls_2013\autotests\temp\src\page-object\pick\serial-numbers.po.js:22:40)
at Generator.next (<anonymous>)
at fulfilled (C:\Users\EBiriukov\Programm\bls_2013\autotests\temp\src\page-object\pick\serial-numbers.po.js:5:58)
From: Task: Run it("Test serial") in control flow
at UserContext.<anonymous> (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\jasminewd2\index.js:94:19) at C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\jasminewd2\index.js:64:48
at ControlFlow.emit (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\events.js:62:21)
at ControlFlow.shutdown_ (C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:2674:10)
at C:\Users\EBiriukov\Programm\bls_2013\autotests\node_modules\selenium-webdriver\lib\promise.js:2599:53
Part of config
export let config: Config = {
directConnect: false,
onPrepare: async () => {
configureReports();
browser.ignoreSynchronization = true;
await loginToTerminal();
},
onComplete: function() {
jasmineOnComplite();
},
specs: [
"src/test-cases/**/*.spec.js"
],
capabilities: {
'browserName' : 'internet explorer',
'platform': 'ANY',
'version': '11',
"nativeEvents": false,
'unexpectedAlertBehaviour': 'accept',
'ignoreProtectedModeSettings': true,
'enablePersistentHover': true,
'disable-popup-blocking': true,
'ignoreZoomSetting': true,
'INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS': true
},
localSeleniumStandaloneOpts : {
jvmArgs : ["-Dwebdriver.ie.driver=./node_modules/protractor/node_modules/webdriver-manager/selenium/IEDriverServer3.4.0.exe"]
},
jasmineNodeOpts: { defaultTimeoutInterval: 260000 },
allScriptsTimeout: 110000,
getPageTimeout: 110000,
}
Any advice how to fix it or at least find what causes this error?

Not navigating pagination3 and getting stale element exception

I need to navigate pages and check services on each page down or up, but while navigating page 3 is showing error message as stale element exception.
I have tried with this code but it's not working fine , someone please help me on this.
public class TC_2377154_12236_Verify_SRS_ServerStatus_LinuxServer {
public static void TC_2377154_12236() {
try {
Assert.done("Start -> TC_2377154_12236");
//BaseSetUp.openBrowser();
WebDriver driver = FrameworkDriver.driver;
driver.get("https://webtech.humana.com/nes/servicesview.aspx");
Assert.assertTrue(driver.findElement(By.xpath("//input[#id='tbLBVServerName']")).isDisplayed(), "LBV Server name is displayed");
driver.findElement(By.xpath("//input[#id='tbLBVServerName']")).sendKeys("SRS");
Assert.assertTrue(driver.findElement(By.xpath("//input[#id='btnFilter']")).isDisplayed(),"Filter button is displayed");
driver.findElement(By.xpath("//input[#id='btnFilter']")).click();
Assert.assertTrue(driver.findElement(By.xpath("//table[#id='dgServices']")).isDisplayed(),"Services name table is Displayed");
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until( ExpectedConditions.presenceOfElementLocated(
By.xpath("//a[#style='color:Black;']")));
List<WebElement> pagination = driver.findElements(By.xpath("//a[#style='color:Black;']"));
int s = pagination.size()/2;
System.out.println(s +"Pagination list");
for(int i=0;i<=s;i++){
List<WebElement> ls = driver
.findElements(By
.xpath("//font[#color='red']"));
System.out.println(ls.size()+"list of Down services size");
if (ls.size() > 1)
Assert.fail("All service states are expected Up and Running but there are "+(ls.size()+" servers are down"));
else if (ls.size() == 0)
Assert.fail("****Some technical issue or No Server is up or running****");
else if (ls.size() == 1)
Assert.pass("~~All Servers are Up and running~~");
Thread.sleep(5000);
// ls.get(i).click();
// Thread.sleep(5000);
System.out.println( pagination.get(i));
//driver.findElement(By.xpath("//a[#style='color:Black;']")).click();
pagination.get(i).click();
Thread.sleep(5000);
}
Assert.done("End -> TC_2377154_12236");
} catch (Exception e) {
Assert.error(e, "Error -> TC_2377154_12236");
}
}
}
I expected output as it should click on each and every page , but getting below error
TC_2377154_12236_Verify_SRS_ServerStatus_LinuxServer-TC_2377154_12236 : PASS - Filter button is displayed
TC_2377154_12236_Verify_SRS_ServerStatus_LinuxServer-TC_2377154_12236 : PASS - Services name table is Displayed
7Pagination list
5list of Down services size
TC_2377154_12236_Verify_SRS_ServerStatus_LinuxServer-TC_2377154_12236 : FAIL - All service states are expected Up and Running but there are 5 servers are down
[[ChromeDriver: chrome on XP (4f932cb86e8057b5ecda92c582500243)] -> xpath: //a[#style='color:Black;']]
TC_2377154_12236_Verify_SRS_ServerStatus_LinuxServer-TC_2377154_12236 : FAIL - Error -> TC_2377154_12236. Error:stale element reference: element is not attached to the page document
(Session info: chrome=77.0.3865.90)
(Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Windows NT 10.0.16299 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'WKR90LDWJ0', ip: '10.94.27.177', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_192'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.37.544315 (730aa6a5fdba15..., userDataDir: C:\Users\VAM1449\AppData\Lo...}, cssSelectorsEnabled: true, databaseEnabled: false, 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: , unhandledPromptBehavior: , version: 77.0.3865.90, webStorageEnabled: true}
Session ID: 4f932cb86e8057b5ecda92c582500243 Stack Trace: [Ljava.lang.StackTraceElement;#18d3f76
FAIL Error:stale element reference: element is not attached to the page document
(Session info: chrome=77.0.3865.90)
(Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Windows NT 10.0.16299 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'WKR90LDWJ0', ip: '10.94.27.177', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_192'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.37.544315 (730aa6a5fdba15..., userDataDir: C:\Users\VAM1449\AppData\Lo...}, cssSelectorsEnabled: true, databaseEnabled: false, 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: , unhandledPromptBehavior: , version: 77.0.3865.90, webStorageEnabled: true}
Session ID: 4f932cb86e8057b5ecda92c582500243 Stack Trace:
org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
(Session info: chrome=77.0.3865.90)
(Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Windows NT 10.0.16299 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'WKR90LDWJ0', ip: '10.94.27.177', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_192'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.37.544315 (730aa6a5fdba15..., userDataDir: C:\Users\VAM1449\AppData\Lo...}, cssSelectorsEnabled: true, databaseEnabled: false, 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: , unhandledPromptBehavior: , version: 77.0.3865.90, webStorageEnabled: true}
Session ID: 4f932cb86e8057b5ecda92c582500243
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
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.RemoteWebElement.execute(RemoteWebElement.java:285)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
at com.humana.hss.scripts.TC_2377154_12236_Verify_SRS_ServerStatus_LinuxServer.TC_2377154_12236(TC_2377154_12236_Verify_SRS_ServerStatus_LinuxServer.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.dell.acoe.framework.run.ExecutionThread.run(ExecutionThread.java:33)
Executing method [TC_2377154_12236]... completed
There is an issue while updating the script status to excel report. Please check file:null
Total:2
Passed:1 50%
Custom Report Generator is configured as:
TC_2377154_12236_Verify_SRS_ServerStatus_LinuxServer-TC_2377154_12236 : DONE - Custom Report Generator is configured as:
is not a valid CustomReportGenerator, it needs package.Class.method format and with two String args
TC_2377154_12236_Verify_SRS_ServerStatus_LinuxServer-TC_2377154_12236 : DONE - is not a valid CustomReportGenerator, it needs package.Class.method format and with two String args
Don't retrieve multiple elements out of For Loop.
You should find each element in For Loop again.
WebElement pag = diver.findElement(By.xpath("(//a[#style='color:Black;'])["+(i+1)+"]"));
Xpath example (you can search in web console):
(//a[#style='color:Black;'])[1]
List<WebElement> pagination = driver.findElements(By.xpath("//a[#style='color:Black;']"));
int s = pagination.size()/2;
System.out.println(s +"Pagination list");
for(int i=0;i<=s;i++){
// Add this line
WebElement pag = diver.findElement(By.xpath("(//a[#style='color:Black;'])["+(i+1)+"]"));
List<WebElement> ls = driver.findElements(By.xpath("//font[#color='red']"));
System.out.println(ls.size()+"list of Down services size");
if (ls.size() > 1)
Assert.fail("All service states are expected Up and Running but there are "+(ls.size()+" servers are down"));
else if (ls.size() == 0)
Assert.fail("****Some technical issue or No Server is up or running****");
else if (ls.size() == 1)
Assert.pass("~~All Servers are Up and running~~");
Thread.sleep(5000);
// ls.get(i).click();
// Thread.sleep(5000);
System.out.println( pagination.get(i));
//driver.findElement(By.xpath("//a[#style='color:Black;']")).click();
// Modify this line
pag.click();
Thread.sleep(5000);
}

"TypeError: rootNode is null" happens when taking screenshots using Selenium framework

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()

Unable to perfrom http basic auth using Browsermob proxy

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);