标签:
http://www.blogjava.net/qileilove/archive/2014/12/11/421309.html
<iframe id="left_frame"
scrolling="auto" frameborder="0" src="index.php?m=Index&a=Menu"
name="left_frame" noresize="noresize" style="height: 100%;visibility: inherit;
width: 100%;z-index: 1">
<!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<body
class="menuBg">
<div
id="menu_node_type_0">
<table width="193"
cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<tr>
<td id="c_1">
<table class="menuSub"
cellspacing="0" cellpadding="0" border="0" align="center">
<tbody>
<tr
class="sub_menu">
<td>
<a
href="index.php?m=Coupon&a=SearchCouponInfo"
target="right_frame">密码重置</a>
</td>
</tr>
|
import java.io.File;
importorg.openqa.selenium.By;
importorg.openqa.selenium.WebDriver;
importorg.openqa.selenium.chrome.ChromeDriver;
importorg.openqa.selenium.support.ui.ExpectedCondition;
importorg.openqa.selenium.support.ui.WebDriverWait;
public classButtonDropdown
{
public static
voidmain(String[] args) throws InterruptedException {
WebDriver dr =
newChromeDriver();
File file =
newFile("src/button_dropdown.html");
String filePath =
"file:///" + file.getAbsolutePath();
System.out.printf("nowaccesss %s
\n", filePath);
dr.get(filePath);
Thread.sleep(1000);
//
定位text是watir-webdriver的下拉菜单
// 首先显示下拉菜单
dr.findElement(By.linkText("Info")).click();
(newWebDriverWait(dr,
10)).until(new ExpectedCondition<Boolean>(){
public
Booleanapply(WebDriver d){
returnd.findElement(By.className("dropdown-menu")).isDisplayed();
}
});
// 通过ul再层级定位
dr.findElement(By.className("dropdown-menu")).findElement(By.linkText("watir-webdriver")).click();
Thread.sleep(1000);
System.out.println("browser
will be close");
dr.quit();
}
}
|
public XiaoyuanactivityPage
zipaixiuye(){
driver.navigate().refresh();
luntan.click();
WebDriverWrapper.waitPageLoad(driver,3);
(new WebDriverWait(driver,
10)).until(newExpectedCondition<Boolean>() {
public Boolean
apply(WebDriverdriver){
returndriver.findElement(By.className("TFB_sub_li")).isDisplayed();
}
});
driver.findElement(By.className("TFB_sub_li")).findElement(By.linkText("自拍秀")).click();
returnPageFactory.initElements(this.getDriver(),
XiaoyuanactivityPage.class);
}
|
org.openqa.selenium.NoSuchElementException:
标签:
原文地址:http://www.cnblogs.com/dieyaxianju/p/5018696.html