selenium webdriver to identify the google play store popup

769 views Asked by At

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

2

There are 2 answers

0
Santoshsarma On

Try with below cssSelectors

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

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

`