我正在使用robotframework和selenium2library測試一個extjs web應用程序,但我找不到一些HTML元素,因爲它們被分配了一個動態ID。robotframework測試extjs應用
例如:selenium2library無法找到一個按鈕,HTML代碼是這樣的:
<button type="button" id="ext-gen56" class=" x-btn-text silk-add">create vm</button>
我曾嘗試使用細節XPath和CSS表達式,但他們沒有工作。如何處理這個問題?任何幫助,將不勝感激。
我使用的工具是robotframework和selenium2library,它們用於自動Web應用程序測試。
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
好像你正在爲你的問題掙扎一點。我試圖編輯您的帖子以顯示實際的HTML代碼,但由於您的重複編輯而被刪除。要顯示HTML代碼,請在包含代碼的行的前面添加4個空格。 – ohaal 2012-02-24 09:12:19
非常感謝。 – 2012-02-24 09:29:17