找不到类DriverSource

时间:2017-05-29 17:15:19

标签: selenium-chromedriver serenity-bdd

我正在使用Serenity BDD(Selenium)在Chrome中运行自动化测试,但在实施客户webdriver代码时无法找到符号:类DriverSource 问题。(尝试在Chrome移动模拟器上测试它) 有谁知道这个问题是什么。感谢

import java.util.HashMap;
import java.util.Map;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.WebDriver;
import java.io.IOException;

public class MobileEmulation implements DriverSource {

@Override
public WebDriver newDriver() {
    try {
            String ChromeDriverPath = System.getProperty("user.dir") + "/chromdrive/chromedriver.exe";
            System.setProperty("webdriver.chrome.driver", ChromeDriverPath);

            Map<String, String> mobileEmulation = new HashMap<String, String>();
            mobileEmulation.put("deviceName", "Google Nexus 5");

            Map<String, Object> chromeOptions = new HashMap<String, Object>();
            chromeOptions.put("mobileEmulation", mobileEmulation);
            DesiredCapabilities capabilities = DesiredCapabilities.chrome();
            capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
            WebDriver driver = new ChromeDriver(capabilities);
            return driver;
        }
    catch (IOException e) {
        throw new Error(e);
    }
}

@Override
public boolean takesScreenshots() {
    return true;
}

}

1 个答案:

答案 0 :(得分:0)

看起来你还没有导入DriverSource类:

import net.thucydides.core.webdriver.DriverSource;