當前位置: 首頁>>代碼示例>>Java>>正文


Java WebDriver.getTitle方法代碼示例

本文整理匯總了Java中org.openqa.selenium.WebDriver.getTitle方法的典型用法代碼示例。如果您正苦於以下問題:Java WebDriver.getTitle方法的具體用法?Java WebDriver.getTitle怎麽用?Java WebDriver.getTitle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openqa.selenium.WebDriver的用法示例。


在下文中一共展示了WebDriver.getTitle方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test

import org.openqa.selenium.WebDriver; //導入方法依賴的package包/類
@Ignore
@Test
public void test() throws IOException {
	Map<String, String> baseState = new HashMap<>();
	baseState.put("type", "MOBILE");
	baseState.put("connectionString", "platformName=Android;app=C:\\apps\\InsuranceMobile.apk");

	DesiredCapabilities capabilities = new DesiredCapabilities();
	capabilities.setCapability("appdriver-basestate", baseState);

	WebDriver driver = new RemoteWebDriver(new URL("http://localhost:8080"), capabilities);
	String title = driver.getTitle();

	assertEquals("", title); // TODO: Maybe we find something to use as the
								// title?

	WebElement email = driver
			.findElement(By.xpath("//MobileTextField[@resource-id='silktest.insurancemobile:id/email']"));
	email.sendKeys("test");
	assertEquals("test", email.getText());
	
	email.clear();
	assertEquals("", email.getText());
	email.sendKeys("[email protected]");

	driver.findElement(By.xpath("//MobileTextField[@resource-id='silktest.insurancemobile:id/password']"))
			.sendKeys("john");

	driver.findElement(By.xpath("//MobileButton[@resource-id='silktest.insurancemobile:id/log_in_button']"))
			.click();

	driver.findElement(By.xpath("//MobileObject[@content-desc='drawer_open']")).click();

	driver.findElement(By.xpath("//MobileObject[@caption='Logout']")).click();

	driver.quit();
}
 
開發者ID:MicroFocus,項目名稱:SilkAppDriver,代碼行數:38,代碼來源:MobileTests.java


注:本文中的org.openqa.selenium.WebDriver.getTitle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。