本文整理汇总了Java中org.openqa.selenium.remote.RemoteWebDriver类的典型用法代码示例。如果您正苦于以下问题:Java RemoteWebDriver类的具体用法?Java RemoteWebDriver怎么用?Java RemoteWebDriver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RemoteWebDriver类属于org.openqa.selenium.remote包,在下文中一共展示了RemoteWebDriver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFirefoxDriver
import org.openqa.selenium.remote.RemoteWebDriver; //导入依赖的package包/类
public static WebDriver getFirefoxDriver()
throws Exception
{
baseDir = new File(".").getPath();
System.out.println("******** " + baseDir);
String path = "src/test/resources/geckodriver";
System.out.println("******** " + path);
System.setProperty("webdriver.gecko.driver", path);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
capabilities.setCapability("networkConnectionEnabled", true);
capabilities.setCapability("browserConnectionEnabled", true);
WebDriver driver = new RemoteWebDriver(
new URL("http://localhost:4444"),
capabilities);
// WebDriver driver = new MarionetteDriver(capabilities);
return driver;
}
示例2: testShippingAddressWithStreet2
import org.openqa.selenium.remote.RemoteWebDriver; //导入依赖的package包/类
@Test
public void testShippingAddressWithStreet2() throws PaymentException {
Payment response = mpay24.paymentPage(getTestPaymentRequest(), getCustomerWithAddress("Coconut 3"));
assertSuccessfullResponse(response);
RemoteWebDriver driver = openFirefoxAtUrl(response.getRedirectLocation());
driver.findElement(By.name("selPAYPAL|PAYPAL")).click();
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.elementToBeClickable(By.name("BillingAddr/Street")));
assertEquals("Testperson-de Approved", driver.findElement(By.name("BillingAddr/Name")).getAttribute("value"));
assertEquals("Hellersbergstraße 14", driver.findElement(By.name("BillingAddr/Street")).getAttribute("value"));
assertEquals("Coconut 3", driver.findElement(By.name("BillingAddr/Street2")).getAttribute("value"));
assertEquals("41460", driver.findElement(By.name("BillingAddr/Zip")).getAttribute("value"));
assertEquals("Neuss", driver.findElement(By.name("BillingAddr/City")).getAttribute("value"));
assertEquals("Ankeborg", driver.findElement(By.name("BillingAddr/State")).getAttribute("value"));
assertEquals("Deutschland", driver.findElement(By.name("BillingAddr/Country/@Code")).findElement(By.xpath("option[@selected='']")).getText());
}
示例3: startApp
import org.openqa.selenium.remote.RemoteWebDriver; //导入依赖的package包/类
@Before
public void startApp() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
Map<String, Object> baseState = new HashMap<>();
baseState.put("type", "NATIVE");
baseState.put("executable", APP);
baseState.put("locator", "//Window");
capabilities.setCapability("appdriver-basestate", baseState);
Map<String, Object> options = new HashMap<>();
options.put("closeOnQuit", true);
capabilities.setCapability("appdriver-options", options);
driver = new RemoteWebDriver(new URL("http://localhost:8080"), capabilities);
}
示例4: download
import org.openqa.selenium.remote.RemoteWebDriver; //导入依赖的package包/类
public static final String download(RemoteWebDriver driver, String url) {
String folder = DOWNLOAD_PATH + RandomStringUtils.randomAlphabetic(10);
new File(folder).mkdirs();
Map<String, String> headers = new HashMap<String, String>();
headers.put("Cookie", getCookie(driver));
byte[] data = HttpUtils.get(url, headers);
try {
String filename;
String contentDisposition = headers.get("Content-Disposition");
if (StringUtils.contains(contentDisposition, "=")) {
filename = contentDisposition.substring(contentDisposition.indexOf("=") + 1);
} else {
filename = new URL(url).getPath();
if (filename.contains("/")) {
filename = filename.substring(filename.lastIndexOf("/") + 1);
}
}
IOUtils.write(data, new FileOutputStream(folder + "/" + filename));
return folder + "/" + filename;
} catch (Exception e) {
throw new RuntimeException("Download failed!", e);
}
}
示例5: testDriver
import org.openqa.selenium.remote.RemoteWebDriver; //导入依赖的package包/类
@Test
public void testDriver() throws IOException {
WebDriver driver = new RemoteWebDriver(toUrl("http://localhost:9515"), DesiredCapabilities.chrome());
driver.get(URL2);
String response = driver.getPageSource();
Document doc = Jsoup.connect(URL2).ignoreContentType(true).get();
Elements scriptTags = doc.select("body");
// get All functions
try {
String result = (String) engine.eval(response);
} catch (ScriptException e) {
e.printStackTrace();
}
log.info("PageSource " + response);
driver.quit();
}
示例6: shouldCreateRemoteDriverInstance
import org.openqa.selenium.remote.RemoteWebDriver; //导入依赖的package包/类
@Test
public void shouldCreateRemoteDriverInstance() throws MalformedURLException {
XmlConfig config = new XmlConfig(new HashMap<String, String>() {
{
put(BROWSER_NAME, "firefox");
put(PLATFORM_NAME, "ANY");
put(TEST_NAME, "shouldCreateRemoteDriverInstance");
}
});
WebDriver driver = mock(RemoteWebDriver.class, RETURNS_DEEP_STUBS);
WebDriverProvider spyFactory = spy(defaultFactory);
Reflect spyReflectedDriver = spy(spyFactory.wrapDriver(firefox));
doReturn(spyReflectedDriver).when(spyFactory).wrapDriver(firefox);
doReturn(on(driver)).when(spyReflectedDriver).create(new URL(firefox.url()), firefox.configuration(config));
assertThat(spyFactory.createDriver(firefox, config)).isInstanceOf(RemoteWebDriver.class);
}
示例7: startApp
import org.openqa.selenium.remote.RemoteWebDriver; //导入依赖的package包/类
@Before
public void startApp() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
Map<String, Object> baseState = new HashMap<>();
baseState.put("type", "NATIVE");
baseState.put("executable", APP);
baseState.put("locator", "//WPFWindow");
capabilities.setCapability("appdriver-basestate", baseState);
Map<String, Object> options = new HashMap<>();
options.put("closeOnQuit", true);
capabilities.setCapability("appdriver-options", options);
driver = new RemoteWebDriver(new URL("http://localhost:8080"), capabilities);
}
示例8: PageObject
import org.openqa.selenium.remote.RemoteWebDriver; //导入依赖的package包/类
protected PageObject(RemoteWebDriver driver, String title, String urlTail) {
this.driver = driver;
this.title = title;
this.urlRoot = "http://localhost:8080";
this.urlTail = urlTail;
this.url = urlRoot + urlTail;
String message = String.format(
"Expected to be on page with"
+ "title containing %s and"
+ "url containing %s but"
+ "title was %s and"
+ "url was %s",
title, url, driver.getTitle(), driver.getCurrentUrl());
assertTrue(message, isCurrentPage());
}
示例9: createRemoteDriver
import org.openqa.selenium.remote.RemoteWebDriver; //导入依赖的package包/类
private static WebDriver createRemoteDriver(String url, DesiredCapabilities caps, Boolean checkForProxy,
Properties props) {
try {
if (isAppiumNative(url, caps.asMap())) {
if (isAndroidNative(caps.asMap())) {
return new io.appium.java_client.android.AndroidDriver(new URL(url), caps);
} else if (isIOSNative(caps.asMap())) {
return new io.appium.java_client.ios.IOSDriver(new URL(url), caps);
}
}
if (url == null) {
return new RemoteWebDriver(caps);
}
if (checkForProxy) {
return new RemoteWebDriver(RemoteProxy.getProxyExecutor(new URL(url), props), caps);
}
return new RemoteWebDriver(new URL(url), caps);
} catch (MalformedURLException ex) {
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
}
return null;
}
示例10: testTokenPaymentWithout3DS
import org.openqa.selenium.remote.RemoteWebDriver; //导入依赖的package包/类
@Test
public void testTokenPaymentWithout3DS() throws ParseException, PaymentException, InterruptedException {
Token token = mpay24.token(getTestTokenRequest(null));
assertEquals("REDIRECT", token.getReturnCode());
assertNotNull(token.getApiKey());
assertNotNull(token.getRedirectLocation());
assertNotNull(token.getToken());
RemoteWebDriver driver = openFirefoxAtUrl(token.getRedirectLocation());
driver.findElement(By.name("cardnumber")).sendKeys("4444333322221111");
driver.findElement(By.name("cardnumber")).sendKeys(Keys.TAB);
driver.findElement(By.id("expiry")).sendKeys("0520");
driver.findElement(By.id("expiry")).sendKeys(Keys.TAB);
driver.findElement(By.name("cvc")).sendKeys("123");
driver.findElement(By.name("cvc")).sendKeys(Keys.TAB);
TimeUnit.SECONDS.sleep(1l);
Payment response = mpay24.payment(getTestPaymentRequest(), getTokenPaymentType(token.getToken()));
assertEquals("OK", response.getReturnCode());
assertNotNull(response.getmPayTid());
}
示例11: testShoppingCartAmounts
import org.openqa.selenium.remote.RemoteWebDriver; //导入依赖的package包/类
@Test
public void testShoppingCartAmounts() throws PaymentException {
Payment response = mpay24.paymentPage(getTestPaymentRequest(120.0, null), getTestShoppingCart());
assertSuccessfullResponse(response);
RemoteWebDriver driver = openFirefoxAtUrl(response.getRedirectLocation());
WebElement element = driver.findElementById("cart");
assertEquals("Rabatt:", element.findElement(By.xpath("tfoot/tr[1]/th")).getText());
assertEquals("-10,00", element.findElement(By.xpath("tfoot/tr[1]/td")).getText());
assertEquals("Versandkosten:", element.findElement(By.xpath("tfoot/tr[2]/th")).getText());
assertEquals("-5,00", element.findElement(By.xpath("tfoot/tr[2]/td")).getText());
assertEquals("Zwischensumme:", element.findElement(By.xpath("tfoot/tr[3]/th")).getText());
assertEquals("100,00", element.findElement(By.xpath("tfoot/tr[3]/td")).getText());
assertEquals("20.00% USt.:", element.findElement(By.xpath("tfoot/tr[4]/th")).getText());
assertEquals("20,00", element.findElement(By.xpath("tfoot/tr[4]/td")).getText());
assertEquals("Gesamtpreis:", element.findElement(By.xpath("tfoot/tr[5]/th")).getText());
assertEquals("EUR 120,00", element.findElement(By.xpath("tfoot/tr[5]/td")).getText());
}
示例12: testLanguageEnglish
import org.openqa.selenium.remote.RemoteWebDriver; //导入依赖的package包/类
@Test
public void testLanguageEnglish() throws PaymentException {
Payment response = mpay24.paymentPage(getTestPaymentRequest(1.0, null, Language.EN), getTestShoppingCart(getTestShoppingCartItemList()));
assertSuccessfullResponse(response);
RemoteWebDriver driver = openFirefoxAtUrl(response.getRedirectLocation());
WebElement element = driver.findElementById("cart");
assertEquals("No.", element.findElement(By.xpath("thead/tr[1]/th[1]")).getText());
assertEquals("Prod. No.", element.findElement(By.xpath("thead/tr[1]/th[2]")).getText());
assertEquals("Product Name", element.findElement(By.xpath("thead/tr[1]/th[3]")).getText());
assertEquals("Amount ordered", element.findElement(By.xpath("thead/tr[1]/th[4]")).getText());
assertEquals("Price/Item", element.findElement(By.xpath("thead/tr[1]/th[5]")).getText());
assertEquals("Total", element.findElement(By.xpath("thead/tr[1]/th[6]")).getText());
assertEquals("Discount:", element.findElement(By.xpath("tfoot/tr[1]/th")).getText());
assertEquals("Shipping Costs:", element.findElement(By.xpath("tfoot/tr[2]/th")).getText());
assertEquals("Subtotal:", element.findElement(By.xpath("tfoot/tr[3]/th")).getText());
assertEquals("Order Total:", element.findElement(By.xpath("tfoot/tr[5]/th")).getText());
}
示例13: testShippingAddress
import org.openqa.selenium.remote.RemoteWebDriver; //导入依赖的package包/类
@Test
public void testShippingAddress() throws PaymentException {
Payment response = mpay24.paymentPage(getTestPaymentRequest(), getCustomerWithAddress(null));
assertSuccessfullResponse(response);
RemoteWebDriver driver = openFirefoxAtUrl(response.getRedirectLocation());
driver.findElement(By.name("selCC|VISA")).click();
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.elementToBeClickable(By.id("cardnumber")));
assertEquals("Testperson-de Approved", driver.findElement(By.name("BillingAddr/Name")).getAttribute("value"));
assertEquals("Hellersbergstraße 14", driver.findElement(By.name("BillingAddr/Street")).getAttribute("value"));
assertNotExistent(driver, By.name("BillingAddr/Street2"));
assertEquals("41460", driver.findElement(By.name("BillingAddr/Zip")).getAttribute("value"));
assertEquals("Neuss", driver.findElement(By.name("BillingAddr/City")).getAttribute("value"));
assertEquals("Ankeborg", driver.findElement(By.name("BillingAddr/State")).getAttribute("value"));
assertEquals("Deutschland", driver.findElement(By.name("BillingAddr/Country/@Code")).findElement(By.xpath("option[@selected='']")).getText());
}
示例14: SeleniumExtension
import org.openqa.selenium.remote.RemoteWebDriver; //导入依赖的package包/类
public SeleniumExtension() {
handlerMap.put(ChromeDriver.class, ChromeDriverHandler.class);
handlerMap.put(FirefoxDriver.class, FirefoxDriverHandler.class);
handlerMap.put(EdgeDriver.class, EdgeDriverHandler.class);
handlerMap.put(OperaDriver.class, OperaDriverHandler.class);
handlerMap.put(SafariDriver.class, SafariDriverHandler.class);
handlerMap.put(RemoteWebDriver.class, RemoteDriverHandler.class);
handlerMap.put(AppiumDriver.class, AppiumDriverHandler.class);
handlerMap.put(List.class, ListDriverHandler.class);
handlerMap.put(PhantomJSDriver.class, OtherDriverHandler.class);
templateHandlerMap.put("chrome", ChromeDriver.class);
templateHandlerMap.put("firefox", FirefoxDriver.class);
templateHandlerMap.put("edge", EdgeDriver.class);
templateHandlerMap.put("opera", OperaDriver.class);
templateHandlerMap.put("safari", SafariDriver.class);
templateHandlerMap.put("appium", AppiumDriver.class);
templateHandlerMap.put("phantomjs", PhantomJSDriver.class);
templateHandlerMap.put("chrome-in-docker", RemoteWebDriver.class);
templateHandlerMap.put("firefox-in-docker", RemoteWebDriver.class);
templateHandlerMap.put("opera-in-docker", RemoteWebDriver.class);
}
示例15: initialise
import org.openqa.selenium.remote.RemoteWebDriver; //导入依赖的package包/类
/**
* Initialises the WebDriver (client).
*
* This method should be called once before each test to ensure that the session state doesn't bleed from one test
* to another (such as user being logged in).
*/
public void initialise() {
final ChromeOptions chromeOptions = new ChromeOptions();
final Map<String, Object> chromePrefs = new HashMap<>();
log.info("Setting WebDriver download directory to '{}'.", downloadDirectory);
chromePrefs.put("download.default_directory", downloadDirectory.toAbsolutePath().toString());
chromeOptions.setExperimentalOption("prefs", chromePrefs);
log.info("Configuring WebDriver to run in {} mode.", isHeadlessMode ? "headless" : "full, graphical");
if (isHeadlessMode) {
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("window-size=1920,1080");
}
webDriver = new RemoteWebDriver(webDriverServiceProvider.getUrl(), chromeOptions);
}