怎样Selenium IDE选择combo box中值

简介:
最近一直在学习 Selenium,打算先从 Selenium IDE入手。IDE 很简单,最重要的就是如何定位目标元素,本人推荐使用CSS来定位你的目标元素。css如何定位在这就不在赘述,google上一堆,对于在 学习遇到的问题,强烈建议使用google, 百度对于技术方面的搜索太渣渣。
  下面我说说我今天遇到的一个问题,今天在写脚本的时候,定位不到combo box中的值。通过google最终找到解决的方法
  一次使用 click, mouserover, click, command命令来选中combo box中的值。
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/login.htm</td>
<td></td>
</tr>
<tr>
<td>selectAndWait</td>
<td>id=ddlWebsite</td>
<td>乐学</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>css=a:contains(&quot;班级管理&quot;)</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=btn1</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>5000</td>
<td></td>
</tr>
<tr>
<td>sendKeys</td>
<td>txtTitle</td>
<td>Selenium</td>
</tr>
<tr>
<td>click</td>
<td>id=comboxText_cbClassCategory</td>
<td></td>
</tr>
<tr>
<td>waitForVisible</td>
<td>id=comboxlist_cbClassCategory</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>css=div.listitem[onclick=OnChangeEvent('cbClassCategory','d9806437-84a1-4b5d-9670-baa5aff64086','脱产班','');;;]</td>
<td></td>
</tr>
<tr>
<td>mouseOver</td>
<td>css=div.listitem[onclick=OnChangeEvent('cbClassCategory','d9806437-84a1-4b5d-9670-baa5aff64086','脱产班','');;;]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=div.listitem[onclick=OnChangeEvent('cbClassCategory','d9806437-84a1-4b5d-9670-baa5aff64086','脱产班','');;;]</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
  如果你要定位的元素 id class name 全相同可以使用这个语法定位你想要定位的值
  css=tag.class[attribute=value]
  ex:css=div.listitem[onclick=OnChangeEvent('cbClassCategory','d9806437-84a1-4b5d-9670-baa5aff64086','脱产班','');;;]   


最新内容请见作者的GitHub页:http://qaseven.github.io/
  
目录
相关文章
|
11月前
|
Web App开发 自然语言处理 IDE
自动化测试之 selenium 的安装以及 selenium IDE 录制自动化脚本的用法
1. 什么是自动化测试 1)单元测试 2)接口自动化 3)UI 自动化 2. Selenium 介绍 1)Selenium IDE 2)Webdriver 3)Selenium Grid 3. 如何使用 Selenium IDE 录制脚本 4. 在 python 环境中安装 Selenium 框架
558 0
|
Web App开发 存储 IDE
5分钟学会制作自动化脚本——自动化脚本辅助开发IDE——Selenium IDE介绍(测试工程师必备)
本文介绍了自动化测试的辅助工具,Selenium IDE的基本使用,有助于自动化工程师辅助编辑自动化脚本,初步建立简单自动化脚本。
344 0
5分钟学会制作自动化脚本——自动化脚本辅助开发IDE——Selenium IDE介绍(测试工程师必备)
|
Web App开发 IDE 测试技术
[python作业AI毕业设计博客]比Selenium IDE更好用的录制工具: Katalon Recorder
Selenium IDE(集成开发环境 Integrated Development Environment)是用于构建测试脚本的原型工具。 它是一个Firefox插件,提供了易于使用的界面,用于开发自动化测试。
|
IDE 测试技术 开发工具