How to handle pop up browser ? (using Robot Framework,python) - python

I am using Robot IDE for creating robot automation test scripts.
For my test the browser is asking for permission to show notification. Since it's a web-based alert dialog I'm not able to access it in my robot script. If I am clicking on the "Allow" button manually then it proceeds to the test and passes successfully. I need to allow the browser to show notification with my robot script.
As you can see from the image I want to click on the Allow button which is necessary to go ahead in my test.
So can anyone know how can I click on the "Allow" button of the browser confirmation popup via the robot test script?

You could just allow or block all the notifications, in this way no pop up will appear
https://support.google.com/chrome/answer/3220216?co=GENIE.Platform%3DDesktop&hl=en

You can disable them using DesiredCapabilities. In this geolocation case, you should use disable-geolocation option.
Here's an example: How can I handle Geo Location popup in browser using selenium webdriver?

Related

Adding Connections on Linkedin with selenium and python

I am trying to add connections on Linkedin with Selenium.
I am running into a problem when I try to click each "Connect Now" button. There is a small window that pops up and the script isn't able to click the button. I have tried to click the link and then use driver.find_element_by_class_name('button-primary-large ml1').click()
Side question - How do I connect large and ml1?
When I run the code, it is clicking to connect but then it has a problem trying to click "Send Now" which is what the code above is trying to do. What is a good way for me to click the send now button? I am posting pictures to show what I mean.
You can click the button by using
driver.find_elements_by_css_selector('.send-invite__actions button.button-primary-large').click()

Handling app download window in selenium using python

I am trying to automate instagram by using selenium and python.
I went till login without any problem.
But after logging in, instagram pops up a window saying "experience the best version of instagram by getting the app" which is a download link of instagram app.
I want to ignore this download pop up window, and having trouble with it
1)no buttons to click, only close(❌) button.
2)xpath of close(❌) button not working
Please help me
And thank you
Since you are saying xpath of close(❌) button not working , you can go try to pass the Escape key to close the pop up window.
In Java
Actions action = new Actions(driver);
action.sendKeys(Keys.ESCAPE).build().perform();
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_ESCAPE);
robot.keyRelease(KeyEvent.VK_ESCAPE);
In Python
webdriver.ActionChains(driver).send_keys(Keys.ESCAPE).perform()
robot = Robot()
robot.press_and_release(Keys.escape)

I want to handle alert as in write `Username and Password` in it and then click OK

The popup comes when we navigate to website and asks for authentication.Something like this. Please let me know how to handle the alert with username and pass, that pops up as this pop up could not be distinguished with firebug etc
I already tried "INPUT TEXT into prompt" #input text into prompt https://username:password#url.com but I get error that There is no alert present. However when I use function Alert should be present it gets passed
I am using robot framework and Selenium2Library.
What you are running into is called BASIC web server authentication. While searching on SO there are a number of similar questions that have been asked over time. This particular one is nice as it has several solution approaches that can be tried.
As the popup is technically not part of the page's DOM, this can not be addressed using xpath. There are roughly two approaches:
Fill in the text boxes using a key stroke simulator like SendKeys.
Prevent the popup from appearing.
In this case you're already on your way for the second one. By including the username and password in the url, the popup is prevented. The following Robot Script uses that example to access a local page that is secured by basic authentication using this tutorial.
*** Settings ***
Library Selenium2Library
*** Test Cases ***
Test Chrome
Create Webdriver Chrome
Go To http://admin:admin#localhost:8090/basic-auth/
Capture Page Screenshot
[Teardown] Close All Browsers
As the popup is prevented, there is no need separately input the username and password.

Prevent accidental close of browser window when there are multiple alerts in selenium with python

I'm writing a test using selenium with python. I'm using PyDev extension in Eclipse.
I'm testing a user management system and of course there is a method to test access permissions. Since there are a lot of links in our system and in some cases may all links be unavailable for the user, there would be a lot of alerts to let the user know about not having permission to access.
Unfortunately, FireFox closes the browser after facing some continuous alerts and the test will exit.
I want to prevent FireFox from this type of behavior and handle alerts by self. I don't want to use that check-box on the FireFox's alert boxes that says "Prevent..."; I need these alerts and I check existence of an alert in order to test the functionality of the system.
That would be great if anyone knows a way to do it for all web-drivers in code, not manually in the browser; since this code will run in some other browsers and some other servers.

how to "allow" firefox internet security automatically

I'm trying to figure out a way to "click" the "Allow" button in firefox internet security window by using pywin32 or windows API. I was able to get the "internet security" window by using FindWindow. I tried to send a button click event but no response and the button looks invisible from spyxx. Any ideas?
Thanks
It's probably not a real Windows button but a XUL widget, so only Firefox knows where it is and what it looks like.
Since your question smells like "I want to write a Trojan", that's as much info I'm willing to give.
[EDIT] Firefox is a very flexible browser, especially when it comes to packaging it. So what you should consider is
package the browser with the settings (obviously this only works if the setting is static)
Write a FF plugin which allows you to do what you want.
Since I've never done this myself, a rough outline: Write a plugin which gets notified when a page is loaded (look into the source of the Greasemonkey add-on for an example; maybe Greasemonkey can already do what you need).
Now if the page loaded contains some special code, your plugin modifies the browser settings. Now all you need to do is to package firefox with this plugin for your IDS suite.
Or maybe you can make the plugin

Categories

Resources