[Selenium] Selenium 疑难杂症
1. jsclick 也不管用
Actions action = new Actions(driver);
WebElement theRow = page.getInvisibleElement();
action.moveToElement(theRow).perform();
page.getInvisibleElement().click(); 或page.getInvisibleElement().click();再获取一遍theRow
2.Issue : Cannot get text of a hidden element, SeleniumUtil. scrollIntoView(element) also doesn’t work for the element
Solution : JavaScript to get the text of hidden element.
Code :
WebElement tickerEl = el.findElement(By.cssSelector("td.auto-left"));
String tickerName = (String) ((JavascriptExecutor) driver).executeScript("return jQuery(arguments[0]).text();", tickerEl);
String tickTmp =StringUtils.trim(tickerName);
logger.info("Ticker : "+tickTmp);
3.Issue : Search function doesn't work sometime after we input the search condition, I guess it may cause by the realization method, the UI may only check the search condition each period of time,
If the input miss the check, we need to input again
Solution : If the drop down list doesn’t display the first time after inputting search condition, clear it and input the search condition again
4.Issue : Cannot get text of the columns which doesn’t show out, we need to drag the scroll bar to make it display when do testing manually.
Solution : Use SeleniumUtil.scrollIntoView(driver, el);
Code :
for (WebElement el : columns) {
if(!(el.isDisplayed())){
SeleniumUtil.scrollIntoView(driver, el);
}
logger.info("Column : " + el.getText());
… …
}
5.问题:元素定位方法没有错,但却定位不到元素
解决方法:发现网页有2个frame,需要定位的元素在左侧frame中,需要先跳转到左边的frame
代码:
6.问题:“确认”按钮通过class name或 css定位不到
解决方法:
通过xpath 定位,再点击
最新文章
- baiduMap
- 想通过加HINT让其走全表扫描
- LinQ的一些基本语句
- mini install centOS log
- php大力力 [025节] 来不及学习和分类的,大力力认为有价值的一些技术文章合集(大力力二叔公)(2015-08-27)
- SQLserver通过链接服务器连接oracle
- 【USACO 2.3.1】最长前缀
- HTML+CSS笔记 CSS中级 颜色&长度值
- uboot的relocation原理具体分析
- NFS 系统搭建 - 成功
- The history of programming languages.(transshipment) + Personal understanding and prediction
- fedora 28 重新生成 /boot/grub2/grub.cfg
- 导入gradle项目
- 登陆 全站 user
- nginx 之 proxy_pass详解
- IE10弹窗showModalDialog关闭之后提示SCRIPT5011:不能执行已释放的Script代码
- CListCtrl使用(转)
- Ubuntu 16.09下iptables通过raw表实现日志输出和调试
- IOZONE测试工具使用方法(转载)
- apk下载安装,存储的位置,路径