0
我在使用Serenity BDD(Selenium)的Chrome中運行自動化測試,但有無法找到符號:class DriverSource在實現客戶webdriver代碼時遇到問題(嘗試在chrome mobile emulator上測試) 有誰知道這有什麼問題。由於找不到代碼DriverSource
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;
}
}