1

I was trying to identify the element in the google play store using firebug the element was identified by the firebug successfully but when I execute the selenium code it throws Invalid selector exception.

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

user2459816
  • 85
  • 2
  • 11
  • Is whatsApp a Google App too now? – Saifur Jun 16 '15 at 12:39
  • Why bother using an XPath when an id is available? Unless you are specifically looking for a child element of another element I would use "//" instead of ".//". – CynicalBiker Jun 16 '15 at 13:54
  • Have you used `getWindowHandles()` to work with the pop-up window? See http://stackoverflow.com/questions/19403949/how-to-handle-pop-up-in-selenium-webdriver-using-java for example – Prophet Jun 17 '15 at 14:53

2 Answers2

0

Try with below cssSelectors

By.cssSelector("button[id='purchase-cancel-button']");
Or
By.cssSelector("div.modal-dialog button[id='purchase-cancel-button']");
Santoshsarma
  • 5,627
  • 1
  • 24
  • 39
0

This item is currently invisible so you have to make a delay for a couple of seconds, f.e.

`

      (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()

`