org.openqa.selenium.NoSuchElementException:
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>
|
element = driver.findElement(By.linkText("密码重置"));
id="left_frame"这个frame里边 所以需要先通过定位frame然后再定位frame里边的某一个元素的方法定位此元素
element
=driver.switchTo().frame("left_frame").findElement(By.linkText("密码重置"));
xiaoshoumingxi_element =
driver.switchTo().frame("left_frame").findElement(By.linkText("销售明细"));
quanzhong_select2 = new
Select(driver.switchTo().frame("right_frame").findElement(By.id("coupon_type_str")));
xpath描述错误
造成找不到元素的情况出现
页面没有加载出来就需要点击页面上的元素
和util来实现
等待欢迎页的图片出现再进行其他操作
wait = (new WebDriverWait(driver,10));
ExpectedCondition<Boolean>(){
Boolean apply(WebDriver d){
loadcomplete =
d.switchTo().frame("right_frame").findElement(By.xpath("//center/div[@class='welco']/img")).isDisplayed();
loadcomplete;
这个是强制线程休息
exception: [Exception... "Component returned failure code: 0x80004005
(NS_ERROR_FAILURE) [nsIDOMNSHTMLDocument.execCommand]" nsresult: "0x80004005
(NS_ERROR_FAILURE)" location:
要取消XMLHttpRequest的跨域限制的话,第一
about:config 里设置 signed.applets.codebase_principal_support = true;
(地址栏输入about:config 即可进行firefox设置)
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); }
catch (e) { alert("Permission UniversalBrowserRead denied."); }
|
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:的更多相关文章
- org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element(识别不到想要的元素) 想获取 ...
- 如果遇到找不到元素如何处理? Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"id","selector":"investmentframe"}
常见几种原因与应对,详细参见http://www.blogjava.net/qileilove/archive/2014/12/11/421309.html 1,动态ID无法找到,用xpath路径解决 ...
- org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launch IE
1.在启动ie浏览器前先加入属性设置一项: DesiredCapabilities ie = DesiredCapabilities.internetExplorer(); ie.setCapabil ...
- selenium:org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
今天用selenium2遇到问题 org.openqa.selenium.WebDriverException: f.QueryInterface is not a function 查了好久最后终于 ...
- Selenium2学习-041-chromedriver:org.openqa.selenium.WebDriverException: unknown error: cannot determine loading status from unexpected alert open
今天在写WebDriver处理弹出框(alert.confirm.prompt)演示实例脚本分发给朋友时,在其执行时未能成功执行,对应的部分错误详情如下: org.openqa.selenium.We ...
- appium运行报错.<init>(Lorg/openqa/selenium/remote/ErrorCodes;Z)V
最近这几天就在学习appium,搭建环境就耗费了很多时间,不得不承认自己够笨的了,然后我把环境搭建好,写完脚本的时候,就报这个错了,当时是从某个群里直接下载的demo,不得不吐槽说,够坑的,是能跑通, ...
- org.openqa.selenium.StaleElementReferenceException
org.openqa.selenium.StaleElementReferenceException如何解啊.什么原因造成的,貌似有时会出现,有时不会出现
- Selenium2学习-038-firefox、webdriver版本不对称问题解决:org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055
今天有个朋友在群里问,为何脚本运行不通过,其脚本操作步骤简单描述如下: 1.启动火狐浏览器 2.打开百度 3.查询框输入关键字 4.点击按钮[百度一下] 脚本挺简单的,其给出的应用报错信息如下所示: ...
- 解决org.openqa.selenium.WebDriverException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms org.springframework.beans.BeanInstantiation
解决方法为将selenium-server-standalone-2.37.0.jar升级至selenium-server-standalone-2.41.0.jar即可. 下载地址:http://s ...
随机推荐
- python-day01 pip 在线安装,标识符规则,注释,变量名,类型
1.python第三方库安装: 在线安装:pip install 库名 pip install 库名 -i 国内源网站地址 离线安装:xxx.tar.gz/rar/zip 解压安装 2.标识符规则: ...
- go之数组
一.数组概念 go语言提供了数组类型的数据结构 数组是具有 [唯一类型] 的一组 [固定长度] 的数据项序列,这种类型可以是任意类型 二.数组声明 var variable_name [SIZE]va ...
- C# 处理oralce 时间
addWorkSql.Append("to_date(' " + DateTime.Now.ToString("yyyy-MM-dd HH:ss:mm") + ...
- 微信小程序特殊字符转义方法——&转义&等等
在我编写公司小程序的过程中,有一次在网页端添加了一张图片,结果在小程序端访问失败了,究其原因,竟然是因为该图片名称中有一个“&”符号,网页端添加后,自动转义成了“&”存储到了数据库.当 ...
- java的封箱和拆箱
1.基本概念 字节的单位:byte.位的单位:bit,1byte=8bit 2.8种基本数据类型 4种整型,2种浮点类型,1种用于表示Unicode编码的字符单元的字符类型和1种用于表示真值的bool ...
- matplotlib之pyplot 知识点滴
以下是一些常用地址链接,请参考 matplotlib 官方网址 plt.plot()函数细节 Matplotlib 中文用户指南 4.6 编写数学表达式 Python seaborn matplotl ...
- 1、Visual Studio Code安装及Hello Word
一.环境初始化 1.下载 Visual Studio Code对应版本安装 2.下载.NET Core 2.0 SDK安装 3.安装Mono Debug 完成后界面如下: 二.创建控制 ...
- 【系列】Java多线程初学者指南(1):线程简介
原文地址:http://www.blogjava.net/nokiaguy/archive/2009/nokiaguy/archive/2009/03/archive/2009/03/19/26075 ...
- 【PL/SQL】匿名块、存储过程、函数、触发器
名词解释 子程序:PL/SQL的过程和函数统称为子程序. 匿名块:以DECLARE或BEGIN开始,每次提交都被编译.匿名块因为没有名称,所以不能在数据库中存储并且不能直接从其他PL/SQL块中调用. ...
- Linux scp 后台运行传输文件
Linux scp 设置nohup后台运行 1.正常执行scp命令 2.输入ctrl + z 暂停任务 3.bg将其放入后台 4.disown -h 将这个作业忽略HUP信号 5.测试会话中断,任务继 ...