У меня проблема, потому что я хочу обработать предупреждение при выполнении 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)##
Для чего вы используете объект 'capability'? – forresthopkinsa