1

У меня проблема, потому что я хочу обработать предупреждение при выполнении javascript. Все в selenium 3.0.1, JDK 1.8 и Firefox версии 51.0.1.Ручка предупреждает, что нет в селене 3 java

Мой код:

public class SeleniumDemo { 

    /** 
    * @param args the command line arguments 
    */ 
    public static void main(String[] args) { 
     // TODO code application logic here 

     System.setProperty("webdriver.gecko.driver", "C:\\Users\\Damian6666\\Downloads\\geckodriver\\geckodriver.exe"); 
     DesiredCapabilities capabilities = DesiredCapabilities.firefox(); 
     capabilities.setCapability("marionette", true); 

     WebDriver driver = new FirefoxDriver(); 
     driver.get("http://wikipedia.org"); 
     JavascriptExecutor jsx = (JavascriptExecutor) driver; 
     jsx.executeScript("alert('Test Alerts');");  

     try { 
      Thread.sleep(3000); 
      Alert alert = driver.switchTo().alert(); 
      alert.accept(); 
     } catch (Exception e) { 
      System.out.println(e); 
     } 
    } 
} 

В выходе я получаю:

INFO: Detected dialect: W3C Exception in thread "main" org.openqa.selenium.WebDriverException: Failed to find value field Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700' System info: host: 'Damian', ip: 'xxx.xxx.x.xxx', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_111' Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, firefoxOptions={args=[], prefs={}}, appBuildId=20170125094131, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=6204, browserVersion=51.0.1, platformVersion=6.1, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt}] Session ID: 912b309c-46a1-4b15-9f9e-f411a6905e87 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.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601) 
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:537) 
at selenium_demo.SeleniumDemo.main(SeleniumDemo.java:35) Picked up _JAVA_OPTIONS: -Xmx1024m Java Result: 1 BUILD SUCCESSFUL (total time: 20 seconds)## 
+0

Для чего вы используете объект 'capability'? – forresthopkinsa

ответ

0

Да, я забыл о возможностях, но когда я добавляю возможности, я получаю все время на выходе:

Exception in thread "main" org.openqa.selenium.WebDriverException: Failed to find value field Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700' System info: host: 'Damian', ip: 'xxx.xxx.x.xx', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_111' Driver info: org.openqa.selenium.firefox.FirefoxDriver 
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, firefoxOptions={args=[], 
rofile=UEsDBBQACAgIAOe1SkoAAAAAAAAAAAAAAAAHAAAAdXNlci5qc51WTW/bMAy971cMOW3AKqTretlOXdcBA4Z1aFDsKMgSbauRJU0fcfPvRmjSRNHbndKbJMS+fj4yOjBUeugfLconGnxiXhWQvdf6oo0TLXMAQHNCgVi8eFtyZSH91exJ2nYAFtrHEhudTAVKj7Z4JGG8lnDWE1rg1qUOwxNbS19uz9Nky788U6CrU6Pjx8vK52xiwAybwR0AAHkB8l86HK4yFK0C34OJhuKbBvB4pr51pgHrupA3URU2D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AAADaAwAAAAA=}, appBuildId=20170125094131, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=8500, browserVersion=51.0.1, platformVersion=6.1, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt}] 
Session ID: bfebaee7-e2f8-430e-a4d6-368f2bc2a30f 
    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.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127) 
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93) 
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42) 
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163) 
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601) 
    at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:537) 
    at selenium_demo.Selenium_demo.main(Selenium_demo.java:38) 
Picked up _JAVA_OPTIONS: -Xmx1024m 
Java Result: 1 
BUILD SUCCESSFUL (total time: 16 seconds) 

 Смежные вопросы

  • Нет связанных вопросов^_^