Selenium frame 简单应用 元素定位
来源:互联网 发布:爱剪辑无法连接网络 编辑:程序博客网 时间:2024/05/01 12:29
在公司做一个selenium的项目,为客户做一个外挂,方便客户操作。遇到了一个找不到元素标签的问题。
private final static String URL = "https://eustg-i.serviceportal.hp.com/"; //网站的地址
private final static String PATH = "/sm-alu/index.do?xHtoken=&event=0&user.id=ASIAPACIFIC_MICROLON&L.language=en&type=login&lang=en"; //网页中的相应一个链接
private final static String BROWSER = "*chrome"; //打开火狐浏览器
private final static String DEFAULT_TIMEOUT = "30000"; //打开页面等待时间
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, BROWSER, URL);
selenium.start();
}
@Test
public void testSM() throws Exception {
selenium.open(PATH);
selenium.click("//div[@id='ROOT/Incident Management']/div");
selenium.click("//div[@id='ROOT/Incident Management/Search Incidents']/a/span");
selenium.selectFrame("//div[@id='cwcCenterPanel']/div[2]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[2]/iframe");
selenium.waitForPageToLoad(DEFAULT_TIMEOUT);
selenium.click("id=X5Button");
selenium.select("id=X5Popup", "label=INCIDENTS My Assignment Group(s)");
selenium.click("css=option[value=\"INCIDENTS My Assignment Group(s)\"]");
selenium.click("id=X31Button");
selenium.select("id=X31Popup", "label=Open");
selenium.click("css=option[value=\"Open\"]");
selenium.selectFrame("relative=up");
selenium.click("//em[button='Search']/button");
selenium.selectFrame("//div[@id='cwcCenterPanel']/div[2]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[2]/iframe");
selenium.waitForPageToLoad(DEFAULT_TIMEOUT);
selenium.selectFrame("//div[@id='list']/div[1]/div[2]/iframe");
selenium.click("//div[@id='x-auto-5']/div/div/div[2]/div/div[3]/table/tbody/tr/td[2]/div");
selenium.selectWindow("null");
selenium.selectFrame("//div[@id='cwcCenterPanel']/div[2]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[2]/iframe");
selenium.selectFrame("//div[@id='detail']/div[1]/div[2]/iframe");
selenium.click("id=X69Button");
selenium.select("id=X69Popup", "label=Analysis/Research");
selenium.click("css=option[value=\"Analysis/Research\"]");
selenium.waitForPageToLoad("1000");
selenium.click("id=X73");
selenium.type("id=X73", "in work");
selenium.selectFrame("relative=up");
selenium.click("//em[button='Save']/button");
System.out.println(selenium.getXpathCount("//body[@id='tpz_body']"));
}
@After
public void tearDown() throws Exception {
// selenium.stop();
}
其中的表达式都是XPath语言,用于定位到相应的元素上。
对应selectFrame的理解,在每次使用的时候,特别要注意你使用的是哪个Frame,因为当你选择了一个frame,你只能从这个frame里面去查找标签元素。如果你要退出当前选择的frame,使用selectWindow("null"),返回到windows的主窗体。
- Selenium frame 简单应用 元素定位
- Python Selenium递归遍历frame定位元素
- Selenium + Webdriver 学习(五) frame下元素定位
- Selenium + Webdriver 学习(五) frame下元素定位
- 关于selenium中定位不到元素,切换frame
- 简单自动化元素定位selenium python
- watir定位元素-frame
- selenium UI元素定位
- selenium 元素定位
- selenium元素定位
- selenium元素定位
- Selenium 如何定位元素
- Selenium元素定位
- selenium webdriver定位元素
- Selenium 元素定位
- Selenium元素定位方式
- Selenium 元素定位
- selenium之元素定位
- 35 架构师不是演员,是管家
- 对进程地址空间的一点认识
- 使用POWERDESIGNER设计数据库的21条技巧
- webkit 流程图
- 设计模式(一)面向对象设计
- Selenium frame 简单应用 元素定位
- Android系统Recovery工作原理之使用update.zip升级过程分析(五)---update.zip包怎样从上层进入Recovery服务
- WebKit加载网页的流程
- extjs与struts2整合实现文件上传之经历
- 黑马程序员 HTML总结二
- 进程的虚拟地址空间
- 怎么查看本地主机名 找本地IP地址
- 安装RedHatLinux6时无法进入图形界面的问题
- DBHelper类