fil*_*d13 2 selenium robotframework selenium-webdriver
我正在使用机器人框架和Selenium2Library库为Web应用程序编写回归测试.我有一个简单的测试,它改变了"帐户设置"类型表单的所有字段(想想用户名,密码,电子邮件等),然后重新访问页面并确保保存了所有数据.像这样:
*** Test Cases ***
Sample Test
Change All Account Details
New Account Details Should Be Saved
*** Keywords ***
Change All Account Details
Navigate to Account Page
Input Text accountSettingFrom_firstname Test
Input Text accountSettingFrom_lastname Dummy
Input Text accountSettingFrom_email new_email@example.com
# etc etc, eventually save the form
New Account Details Should Be Saved
Go To ${ACCOUNT_URL}
Textfield Value Should Be accountSettingFrom_firstname Test
Textfield Value Should Be accountSettingFrom_lastname Dummy
Textfield Value Should Be accountSettingFrom_email new_email@example.com
Run Code Online (Sandbox Code Playgroud)
Textfield Value Should Be accountSettingFrom_email new_email@example.com运行此测试时,我在最后一步()上收到以下错误:Value of text field 'accountSettingFrom_email' should have been 'new_email@example.com' but was 'None'
我已经在该步骤运行之前拍摄了屏幕截图,并且我添加了暂停并手动确认value"accountSettingFrom_email" 的属性确实是"new_email@example.com".检查发生时元素的HTML:
<input type="email" name="accountSettingFrom[email]" value="new_email@example.com" class="foo bar" required="required" tabindex="3" maxlength="128" url="/foo/bar" userid="foobar" id="accountSettingFrom_email">
Run Code Online (Sandbox Code Playgroud)
您会注意到前两个Textfield Value Should Be关键字通过了.我可以在三个元素之间区分的唯一区别是'accountSettingFrom_email' type="email"代替type="text",但如果关键字成功定位元素,那么为什么它不能获取value属性的值?
我做错了什么?我觉得必须存在这个或类似的关键字来测试它,而不必求助于编写自定义库.
您已经在Selenium2Library中遇到了一些错误.创建Selenium2Library时,HTML5未被批准.在内部,库会过滤掉你的元素,因为它的类型不是"text"(在HTML5之前有意义).Textfield Value Should Be如果元素具有标记名称输入且属性值为"text",则只能找到您的元素.请参阅https://github.com/robotframework/Selenium2Library/issues/546
同样由于如何Textfield Value Should Be实现,您获得的错误使您认为该元素被发现,实际上它不是因为它被过滤掉了.请参阅https://github.com/robotframework/Selenium2Library/issues/547
相比之下,Input Text并且Input Password从未过滤过元素标签或属性.
| 归档时间: |
|
| 查看次数: |
3415 次 |
| 最近记录: |