0

Once in a while I get an alertbox that crashes my test. I did add the following line to my code, but I still get the following exception

options.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);

Below is the exception

org.openqa.selenium.UnhandledAlertException: : 
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:25:02.294Z'
System info: host: 'firefox', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.13.0-36-generic', java.version: '1.8.0_151'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 58.0.2, javascriptEnabled: true, moz:accessibilityChecks: false, moz:headless: true, moz:processID: 10211, moz:profile: /tmp/rust_mozprofile.yshC1I..., moz:webdriverClick: true, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, platformVersion: 4.13.0-36-generic, rotatable: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}}
Session ID: c995dd63-3b01-4c6f-84cd-4434bb104829
*** Element info: {Using=id, value=titletextonly}
        at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120)
        at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:160)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
        at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:371)
        at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:417)
        at org.openqa.selenium.By$ById.findElement(By.java:218)
        at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)
        at clscraper.Scraper.run(Scraper.java:68)
        at java.lang.Thread.run(Thread.java:748)
Exception in thread "Thread-0" org.openqa.selenium.UnhandledAlertException: : 
Build info: version: '3.9.1', revision: '63f7b50', time: '2018-02-07T22:25:02.294Z'
System info: host: 'firefox', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.13.0-36-generic', java.version: '1.8.0_151'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 58.0.2, javascriptEnabled: true, moz:accessibilityChecks: false, moz:headless: true, moz:processID: 10211, moz:profile: /tmp/rust_mozprofile.yshC1I..., moz:webdriverClick: true, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, platformVersion: 4.13.0-36-generic, rotatable: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}}
Session ID: c995dd63-3b01-4c6f-84cd-4434bb104829
        at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120)
        at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:160)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:658)
        at org.openqa.selenium.remote.RemoteWebDriver.close(RemoteWebDriver.java:487)
        at clscraper.Scraper.run(Scraper.java:93)
        at java.lang.Thread.run(Thread.java:748)
Arya
  • 7,765
  • 24
  • 86
  • 160
  • @KirilS. it's not a duplicate. I'm getting unexpected results. – Arya Mar 13 '18 at 16:35
  • did you read the accepted answer? – ohglstr Mar 13 '18 at 16:39
  • @KirilS. yes I read that before I posted this – Arya Mar 13 '18 at 16:54
  • Found out it's not supported in the geckodriver https://github.com/mozilla/geckodriver/issues/990 – Arya Mar 13 '18 at 17:03
  • that solution catches the exception in case of UnhandledAlertException and in case of no alert, and prints what alert had to say. So... what in that solution doesn't work for you? – ohglstr Mar 13 '18 at 17:05
  • the try catch method may work. you are right. When I looked at that I did not know that `UnexpectedAlertBehaviour` is not implemented in Geckodriver – Arya Mar 13 '18 at 17:32

0 Answers0