selenium webdriver to identify the google play store popup - selenium

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.

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

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

Related

How to get rid of google pop-ups while testing and navigation google url?

Every time I navigate to google through Selenium, I encounter this popup. I can't click on the search bar. Is there a way to close permanently this popup without using any JS alert method etc.?
I tried some extensions but it didn't work
Click the Lock button (🔒) on the top-left of the search box
Click on 'Cookies'
Make sure you're on 'allowed' and find anything on the lines of google.com
Click Block, Done and refresh the page
Additionally, you may want to try it first without the web-driver 'Chrome is being controlled by automated test software' mode, so open Google Chrome you way you usually would.

Testcafe Browserstack IE11- Clicking on button doesn't work

Error: Button click doesn't perform action as expected, page is being Idle
Current behavior: It's clicking on a button but it's not performing any action
Expected behavior: Manually it works! expected the button click should move to the next page
Tried using Press key, hover, Client function for Selector
Unfortunately I couldn't provide more details of the application but I will appreciate providing workarounds
Seems like it was fixed in TestCafe v1.9.1.

Handle JavaFX popup in selenium

When i click on patient ,i will get a JavaFX popup .How can i handle the same using selenium?
I have to check the title and click on OK
When i add the driver to watch list
i am doing
fxdriver.findElement(By.cssSelector("text[text*='discharged']").getText() - return nothing
I just cant inspect the same and i have created a fxdriver which handles the page but when the popup comes out i cant do anything with the application (application freezes out) until i click on OK in the popup

How to click on alert box ok button using nightwatch.js

I am working on ui automation testing using nightwatch.js, i am struggling on a point, i want to click on alert box's "OK" button but i am unable to do it because i didn't find anyway to press alert box's "OK" button on browser using nightwatch.js.
is there any way please suggest.
You can use the Selenium acceptAlert protocol. It can be used like this:
browser
.url(APP_ROOT)
.waitForElementVisible('.classThatOpensAlert', 2000)
.click('.classThatOpensAlert')
.pause(1000)
.acceptAlert()

Automating "Browse" button event in Selenium

I need to automate the "Browse" button click from Selenium.
For this, I have tried
driver.findElement(By.xpath("//*[#id=\"dnn_ctr383_View_filename\"]")).click();
and
driver.findElement(By.cssSelector("Css path")).click();
Both gives me org.openqa.selenium.NoSuchElementException: Unable to locate element: exception.
I have seen this link here where the author suggest to use AutoIT, but in step 2, the script, the author has created is for IE. Can someone please suggest, how I can automate the "Browse" button click in firefox?
Any help is much appreciated.
Directly send the file path to the id, like so
driver.findElement(By.id("dnn_ctr383_View_filename")).sendKeys("C:\\path\\to\\file");
The above step is the answer for your first two steps
Click on Browse
Select a file to upload
For the third step(click upload), looking at the screen capture I do not see any button which says "Upload". So just click "Save" and I assume that your file will successfully get uploaded.
There are two things that u need to consider here:
Clicking the browser button: Usually handled by an alert or popup, if the driver is not able to find the element by xpath(which u have acquired from firebug or chrome's inspect element) you should consider looking for iframes in the page source. If an element is in a different frame altogether , u need to switch frames in order to find the element like this
WebElement frame = driver.findElementById("name_of_iframe");
driver.switchTo().frame(fr);
now you can find your element using xpath or css selector like u did. Once completed u can move out of the frame by:- driver.switchTo().defaultContent();
Uploading the file from desktop: Since selenium works only on the html in the browser session u invoked from the driver, it can't perform operations on your desktop.Once you are able to click the browser button u can use Auto it(works only on windows) or Sikuli(works with mac, linux, windows and even android) to simulate your events based on the position of your upload button.
Hope this helps