WebDriver错误InvalidArgumentException:隐式使用时缺少“类型”参数

时间:2018-08-02 06:31:30

标签: java selenium selenium-webdriver

如果我在代码中使用driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);,则会收到错误消息

 Exception in thread "main" org.openqa.selenium.InvalidArgumentException: Missing 'type' parameter

请有人提出原因。如果我发表评论,代码可以正常工作。我正在使用以下版本: 硒3.12.0 Firefox- v50.0 GeckoDriver- v0.14.0

使用的代码:

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
public class Gmail1 {

public static void main(String[] args) {
    System.setProperty("webdriver.gecko.driver", "D:\\Drivers\\geckodriver.exe");
    ProfilesIni profile = new ProfilesIni(); //all profiles 
    FirefoxProfile prof = profile.getProfile("Abhi_Selenium");
    FirefoxOptions opt = new FirefoxOptions();
    opt.setProfile(prof);

    WebDriver driver = null;
    driver = new FirefoxDriver(opt);
    driver.get("http://gmail.com"); 
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    WebElement e = driver.findElement(By.xpath("//a[@class = 'gmail-nav__nav-link gmail-nav__nav-link__sign-in']"));
    e.getText();
    e.click();

控制台错误:

1533183837028   addons.xpi-utils    DEBUG   XPI Database saved, setting 
schema version preference to 17
console.error: PushService: 
stateChangeProcessEnqueue: Error transitioning state
UnknownError
Aug 02, 2018 9:53:58 AM org.openqa.selenium.remote.ProtocolHandshake 
createSession
INFO: Detected dialect: W3C
Exception in thread "main" org.openqa.selenium.InvalidArgumentException: 
Missing 'type' parameter
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05- 
08T15:15:03.216Z'
System info: host: 'ABHISHED-W10LT', ip: '10.210.25.208', os.name: 'Windows 
10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {XULappId: {ec8030f7-c20a-464f-9b0e-13..., acceptInsecureCerts: 
true, acceptSslCerts: false, appBuildId: 20161104212021, browserName: 
firefox, 
browserVersion: 50.0, command_id: 1, firefox_profile: 
UEsDBBQACAgIALlOAk0AAAAAAAA..., javascriptEnabled: true, platform: XP, 
platformName: XP, platformVersion: 10.0, processId: 23732, proxy: Proxy(), 
raisesAccessibilityExceptions: false, rotatable: false, specificationLevel: 
0, 
takesElementScreenshot: true, takesScreenshot: true, version: 50.0}
Session ID: 1801e7b1-dee1-41d2-8315-dce8e8d808e1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)

1 个答案:

答案 0 :(得分:0)

这是一个兼容性问题。我将firefox升级到v53.0,并将geckodriver升级到v0.18.0。它解决了问题。