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

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

Related

How to change the focus from chrome browser to internet explorer using selenium webdriver?

Scenario :
There is a button/link on a page opened in chrome browser and after clicking on a button/link it will navigate to the other link and opens in systems default browser i.e. Internet Explorer.
How to change the focus from chrome browser to internet explorer in selenium?
This is not possible.
You are starting your Chrome browser using the Chromedriver. You cannot handle Internet Explorer with your Chromedriver. You would need to use the IEDriver.
But as you did not start Internet Explorer using Selenium you would need to re-use an existing session. This is officially not supported see.
Nevertheless Tarun Lalwani was able to achieve this. See here and here.
I would suggest to save the link of the button/link before clicking on it and then start a new session using Internet Explorer and navigate to the saved link.

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?

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 do I enable popups in a new Firefox profile using selenium webdriver (Java)

The application I am testing requires pop-up to be enabled. When a launch a new Firefox profile I get the browser message
Firefox prevented this site from opening a pop-up window
with a button on the right called Options. I can manually click the Options button and select to Allow popups from ....
Question is how can I use profile.setPreference to set to allow popups from my website and also not show this Firefox message?
You can save your current Firefox prifile with allowed popups and load it from file like in this case: https://stackoverflow.com/a/6830109/1165331
save you current working profile with popups via browser and loat it.

Selenium - dialog box

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.