我試圖與硒的演練用於搜索的特價機票,在網站上。我已經能夠完成所有的搜索過程,但現在我被選中的航班卡住了。我設法按公司名稱訂購航班。現在我需要點擊兩個首航(出發,到達)。硒 - 點擊自動生成隨機DIV/ID/LINK
正如你所附加的圖像上看到,網頁生成兩個表。他們每個人都列出了一些航班。我需要點擊每個表格的第一個。
的問題是,生成的列表使用不同的DIV的ID爲不同的公司,而且標識具有隨機數(「_X」,X是一個隨機數)。
我只需要點擊每個表的DIV的,任何comlumn應該做到這一點。但是所有列都使用相同的名稱(在兩個表上)。
使用Selenium IDE現在的工作,但僅僅幾個小時,因爲航班,價格,時間不斷更新和網頁顯示每個時間,這意味着不同的ID,每次不同的結果。
有沒有辦法解決這個問題?
重要提示:我使用JAVA硒。沒有PERL,沒有PYTHON或其他。
這將是現在使用JAVA的步驟:
// This orders the departure flight by company.
selenium.click("id=orden-compania-ida");
selenium.click("id=orden-compania-ida");
// This orders the arrival flights by company.
selenium.click("id=orden-compania-vuelta");
selenium.click("id=orden-compania-vuelta");
// This would click on the first link of first table
selenium.click("css=div.col-3 > label");
selenium.click("id=I_5");
// This would click on the first link of the second table
selenium.click("css=#TV_GDSAMADEUS_7 > div.col-3 > label");
selenium.click("id=V_12");
此時這個工作,但飛行更新後,這將不再工作。有沒有什麼辦法可以讓硒點擊每張桌子右側的第一次飛行?
非常感謝。
問題是我使用的是Selenium RC,而不是webdriver。並且不支持「driver.findElements」... – 2012-02-21 08:00:08