尝试使用硒4

时间:2019-12-11 22:24:52

标签: java selenium selenium-webdriver selenium-chromedriver

我正在使用Selenium 4.0.0-alpha-3,webdrivermanager 3.7.1,Chrome浏览器79, Chrome驱动程序4.0.0-alpha-3,JAVA

代码如下:

WebDriverManager.chromedriver().setup();
driver = new ChromeDriver(options);
driver.get("www.Url1.com");     
driver.switchTo().newWindow(WindowType.TAB);
// below code line is throwing error
driver.get("www.Url2.com");

下载了Maven依赖项,这就是我下载的-

<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>3.7.1</version>
</dependency>
<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.6</version>
</dependency> 

错误跟踪:

  

org.openqa.selenium.InvalidArgumentException:无效参数     (会议信息:chrome = 79.0.3945.79)   内部版本信息:版本:“ 4.0.0-alpha-3”,修订版:“ 8c567de6dc”   系统信息:主机:'IL-mike',ip:'10 .16.240.29',os.name:'Windows 10',os.arch:'amd64',os.version:'10 .0',java.version:'12 .0 .1'   驱动程序信息:org.openqa.selenium.chrome.ChromeDriver   功能{acceptInsecureCerts:false,browserName:chrome,browserVersion:79.0.3945.79,chrome:{chromedriverVersion:79.0.3945.36(3582db32b3389 ...,userDataDir:C:\ Users \ mike \ AppData \ Loc ...},goog:chromeOptions :{debuggerAddress:localhost:56216},javascriptEnabled:true,networkConnectionEnabled:false,pageLoadStrategy:正常,平台:WINDOWS,platformName:WINDOWS,代理:Proxy(),setWindowRect:true,strictFileInteractability:false,超时:{隐式:0, pageLoad:300000,脚本:30000},unhandledPromptBehavior:关闭并通知}   会话ID:e65fde07f0a168c2399049ab2ffe5866       在java.base / jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(本地方法)       在java.base / jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)       在java.base / jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)       在java.base / java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)       在java.base / java.lang.reflect.Constructor.newInstance(Constructor.java:481)       在org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:191)       在org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:125)       在org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:52)       在org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:161)       在org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)       在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:576)       在org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:276)       在       在java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(本机方法)       在java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)       在java.base / jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)       在java.base / java.lang.reflect.Method.invoke(Method.java:567)

1 个答案:

答案 0 :(得分:0)

请尝试使用driver.get()来运行它,而不是运行另一个driver.execute_script("replace.window.location{"www.Url2.com"}")