Selenium - dialog box - selenium

When the browser launch is initiated by SeleniumRC, a dialog box always comes to ask for username/password to login to our proxy server (however, it is prepopulated with username/password, all has to be done is just press the OK button).
selenium.open("/");
selenium.type("q", "selenium rc");
selenium.click("btnG");
selenium.waitForPageToLoad("10000");
assertTrue(selenium.isTextPresent("Results * for selenium rc"));
// These are the real test steps
//selenium.stop();
After the first command, the dialog box appears and I want to dispose of that dialog box PROGRAMMATICALLY. Any help?

I don't think you'll be able to address this just by using Selenium, that modal dialog is outside the JavaScript boundaries in which selenium works.
The two alternatives I can think of are:
Using WebDriver (soon to be merged into selenium 2.0): has native support over the browser, which allows you to do that kind of stuff.
Using an OS level automation library just for clicking that prompt and you go back to selenium with the rest. The libs available for this things are language dependent, so you will find a lot of different options as Robot for java or pyWinAuto for python.
Update: New alternative:
You can use autoIT as a simple and fast solution under windows.

Related

How to bring browser to front using Selenium WebDriver?

I've a test where it handles login system popup using Robot of Java. But because of some issues, other applications or browser instance come to front and Robot could not perform actions on system popup of Windows.
Hence before interacting with system popup using Robot, I want to bring that browser to front on machine. I tried following but it did not help -
((JavascriptExecutor)driver).executeScript("window.focus();");
Could you please suggest how I can bring it to the front?

How to upload image using selenium webdriver (Mac)

Unable to Upload image using selenium web driver in MAC
HTML content having a button "choose Photo", on clicking it upload window will be opened.
AS code doesn't have an input type as file I couldn't use Send Keys .
I have tried the Robot class, but it has the constraint that we couldn't run in the background.
Kindly suggest the methods can be used on MAC .(Am able to successfully upload using AutoIT in windows)
Thanks
Kavitha S
Usually the choose Photo button will make us interact with the desktop, Selenium works on web-based applications. AutoIt can work well because it is intended for desktop applications.
I agree with #Frian answer that selenium web driver only works on the browser. However, from my understand I’m not sure if AutoIt is compatible with Mac you may have to use an alternative. You can find a list of alternatives here - alternativeto.net/software/autoit/?platform=mac

How can I access browser extension's popup using selenium?

I want to write an acceptance test for my browser extension. I've tried to initiate an extension via selenium but I can't seem to access a content of popup. Can someone suggest how can I do it with selenium or any other way to write UI/acceptance tests for browser extensions? Thanks.
How can I access browser extension's popup using selenium?
It's not possible. Selenium supports interaction with web view only.
What you can do with Selenium and extension for sure is automatic installation: https://stackoverflow.com/a/16512012/2517622
You may try to use desktop automation tools (e.g. White on Windows platform) for clicking on extension popup but it's not that easy and it's not platform independent as Selenium.
Here is the workaround we came up. Unless someone posts here the "right" solution I will consider this as the best approach.
So eventually, our extension is an iframe which just loads a page content from our website + does some other neat stuff. We simply open that url in a new tab and do regular selenium tests.
Side not: we have considered to write a little javascript wrapper to be able to access ext via main window through javascript. E.g. there is some js in ext that listens to main window's events and perform certain actions. Tho, it is too much efforts and doesn't really sound like a proper acceptance test so we discarded this approach.

Selenium Golang binding without server

There are many selenium webdriver binding package of Golang.
However, I don't want to control browser throught server.
How can I control browser with Golang and selenium without selenium server?
You can try github.com/fedesog/webdriver which says in its documentation:
This is a pure go library and doesn't require a running Selenium driver.
I would characterize the Selenium webdriver as a client rather than a server. Caveat: I have used the Selenium webdriver (Chrome version) from .Net and I am assuming it is similar for Go.
The way Selenium works is that you will launch an instance of it from within code, and it creates a live version of the selected browser (i.e. Chrome) and your program retains control over it. Then you write code to tell the browser to navigate to a page, inspect the response, and interact with the browser by filling out form data, clicking on buttons, etc. You can see what is happening on the browser as the code runs, so it is easy to troubleshoot when the interaction doesn't go as planned.
I have used Selenium to upload tens of thousands of records to a website that has no API and only a graphical user interface. Give it a chance.

How to disable developer tools in webpage opened by selenium driver?

I have created an application in selenium wherein it opens IE browser and enters user id and password by usind selenium's IE driver. However I want to prevent user from inspecting the auto data filled by selenium in the form. User can easily inspect the data using developer tools. So I want to know the way to disable developer tools options in selenium opened webpages.
Your help is highly appreciable.
Thanks.
Instantiate an instance of OpenQA.Selenium.Interactions.Actions then perform keystrokes for the F12 control. This should toggle on/off the developer tools in Chrome, IE, and Firefox.
I would also include a check to see if one of the controls from the devtools is there before toggling this, just to be sure that you don't turn them on instead of off.
c#:
OpenQA.Selenium.Interactions.Actions actions = new OpenQA.Selenium.Interactions.Actions([Instance of IWebDriver goes here]);
actions.SendKeys(OpenQA.Selenium.Keys.F12).Perform();