我正在使用robotframework 和selenium2library 测试一个extjs Web 应用程序,但是我找不到一些HTML 元素,因为它们被分配了一个动态ID。
例如: selenium2library 找不到一个按钮,其中 html 代码如下:
<button type="button" id="ext-gen56" class=" x-btn-text silk-add">create vm</button>
我曾尝试使用详细的 XPath 和 css 表达式,但它们不起作用。如何处理这个问题?任何帮助,将不胜感激。
我使用的工具是用于自动 Web 应用程序测试的 robotsframework 和 selenium2library。
Parts of my test script:
// filename is A.txt
//this is a resource file including keywords which are used by testcase file
*** Keywords ***
open vmmanager page
[Timeout]
click element xpath=//table[3]/tbody/tr[2]/td[2]/em/button
create vm
[Arguments] ${vm_name} ${input_description}
click element xpath=//table[3]/tbody/tr[2]/td[2]/em/button
click element xpath=//td[2]/table/tbody/tr[2]/td[2]/em/button
click link xpath=//tbody/tr/td[5]/div/a
click link xpath=//tbody/tr/td[7]/div/a
input text xpath=//div/div/input ${vm_name}
click image xpath=//div/div/img
click element xpath=//div[22]/div/div
click image xpath=//div[3]/div/div/img
click element xpath=//div[19]/div/div
name is null
alert should be present ${expect}
click button xpath=//div[2]/div/div/div/div/table/tbody/tr/td/em/button
click button xpath=//td[5]/table/tbody/tr[2]/td[2]/em/button
contact engineer
alert should be present
click button ext-gen311
//filename is B.txt
//this is testcase file
*** Settings ***
Resource fiel A.txt
*** Test Cases ***
VC_VM_01
open vmmanager page
create vm ${empty} description
name is null
VC_VM_03
open vmmanager page
create vm valentine day
contact engineer