selenium webdriver识别谷歌播放商店弹出窗口

时间:2015-06-16 12:19:41

标签: selenium selenium-webdriver selenium-rc

我试图使用firebug识别google play商店中的元素,该元素由firebug成功识别,但是当我执行selenium代码时,它会抛出Invalid选择器异常。

1. Login to playstore with the gmail account.
2. In the search box, type whatsapp and click on install button
3. It opens popup, I wanted to click on dropdown values and then click on install or just click on cancel button

For the cancel button, I wrote the following code:
driver.findElement(By.xpath(".//*[@id='purchase-cancel-button']")).click();
which is not working.

enter image description here

2 个答案:

答案 0 :(得分:0)

尝试使用以下cssSelectors

By.cssSelector("button[id='purchase-cancel-button']");
Or
By.cssSelector("div.modal-dialog button[id='purchase-cancel-button']");

答案 1 :(得分:0)

此项目目前是不可见的,因此您必须延迟几秒钟,例如

`

      (driver.find_element_by_xpath(
                '//*[@id="body-content"]/div/div/div[1]/div[1]/div/div[1]/div/div[3]/div/div[1]/span/span/button')).click()

      time.sleep(4)

      (driver.find_element_by_xpath('//*[@id="purchase-ok-button"]')).click()

`