简体   繁体   English

错误:(34、12)java:不兼容的类型:java.lang.String无法转换为org.openqa.selenium.WebDriver

[英]Error:(34, 12) java: incompatible types: java.lang.String cannot be converted to org.openqa.selenium.WebDriver

ı have trouble with this error, and i can not see any sensible mistake from code 我有这个错误的麻烦,我从代码中看不到任何明智的错误

package driver;

import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class DriverFactory {

    // Get a new WebDriver Instance.
    // There are various implementations for this depending on browser. The required browser can be set as an environment variable.
    // Refer http://getgauge.io/documentation/user/current/managing_environments/README.html
    public static WebDriver getDriver() {

        String browser = System.getenv("BROWSER");
        if (browser == null) {
            WebDriverManager.chromedriver().setup();
            return new ChromeDriver();
        }
        switch (browser)
        {
            case "IE":
                WebDriverManager.iedriver().setup();
                return new InternetExplorerDriver();
            case "FIREFOX":
                WebDriverManager.firefoxdriver().setup();
                return new FirefoxDriver();
            default:
                WebDriverManager.chromedriver().setup();
                return new ChromeDriver();

        }
    }
}

Error:(34, 12) java: incompatible types: java.lang.String cannot be converted to org.openqa.selenium.WebDriver 错误:(34、12)java:不兼容的类型:java.lang.String无法转换为org.openqa.selenium.WebDriver

It solved with review pom.xml dependencies It should be just like this, 它通过审查pom.xml依赖关系解决了就像这样,

http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 http://maven.apache.org/maven-v4_0_0.xsd“> 4.0.0

<groupId>com.thoughtworks.gauge.maven</groupId>
<artifactId>gauge-archetype-java</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
    <dependency>
        <groupId>com.thoughtworks.gauge</groupId>
        <artifactId>gauge-java</artifactId>
        <version>0.6.7</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.1.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.0.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.github.bonigarcia</groupId>
        <artifactId>webdrivermanager</artifactId>
        <version>3.6.1</version>
    </dependency>

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>22.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.thoughtworks.gauge.maven</groupId>
            <artifactId>gauge-maven-plugin</artifactId>
            <version>1.3.0</version>
            <executions>
                <execution>
                    <phase>test</phase>
                    <configuration>
                        <specsDir>specs</specsDir>
                    </configuration>
                    <goals>
                        <goal>execute</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:不兼容的类型:java.lang.String 无法转换为 String - error: incompatible types: java.lang.String cannot be converted to String BlueJ错误:“不兼容的类型:int无法转换为java.lang.String”和“不兼容的类型:java.lang.String无法转换为int” - BlueJ Error: “Incompatible types: int cannot be converted java.lang.String” AND “Incompatible types: java.lang.String cannot be converted to int” BlueJ错误:不兼容的类型:java.lang.String无法转换为java.lang.String [] - BlueJ error: incompatible types: java.lang.String cannot be converted to java.lang.String[] 不兼容的类型:java.lang.Object无法转换为org.openqa.selenium.WebElement - incompatible types: java.lang.Object cannot be converted to org.openqa.selenium.WebElement JAVA:不兼容的类型:int 无法转换为 java.lang.String - JAVA: Incompatible types: int cannot be converted to java.lang.String Java:不兼容的类型:java.lang.String 不能转换为 int - Java:incompatible types: java.lang.String cannot be converted to int java:不兼容的类型:T 无法转换为 java.lang.String - java: incompatible types: T cannot be converted to java.lang.String 不兼容的类型:java.lang.String无法转换为布尔值 - Incompatible types: java.lang.String cannot be converted to boolean 不兼容的类型:卡无法转换为java.lang.String - Incompatible types: Card cannot be converted to java.lang.String 不兼容的类型:java.lang.String 不能转换为 int[] - incompatible types: java.lang.String cannot be converted to int[]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM