How to open Edge in inprivate mode using selenium? - selenium-edgedriver

I am using the following code(C#) but its not working:
EdgeDriver driver = new EdgeDriver();
driver.Navigate().GoToUrl("about:InPrivate");
driver.Navigate().GoToUrl(myurl);
This is opening normal window instead of inprivate window.
How to open this using selenium?

Related

The browser opened by geckodriver, is not using default settings for running Robot script

I've set layout.css.devPixelsPerPx in Firefox to be 0.9 (open a new tab, write "about:config" & hit Enter), since I want the browser to be opened with certain level of zoom aspect. It is working fine, when I'm opening the browser manually.
But when I run a robot script, it opens the browser with zoomed in instead of the one, already set above.
So far I've tried following options, apart from above -
1. Tried using Firefox extension, which set default zoom level, but the browser opened by Geckodriver, doen't have that extension available.
2. Run Cntrl+- to zoom out, but as soon as the url changes, the zoom is reset to 100%
3. I can have the Browser open with a command (which has the correct zoom level set). Is there a way, I can ask Robot to use the existing instance of browser than opening new one?
How can I have the Robot open the Firefox browser with certain level of zoom?
The reason why you don't see the setting effective when you run the script is because Selenium creates a new profile when it starts a browser.
Any changes you do in your browser, any extensions you add, are stored in your user's profile. Selenium uses a clean/vanilla (as in: having the default settings) profile so your testing environment is always clean - not influenced by customizations, extensions, cached resources you may have added in your daily work.
If you want to have a particular setting changed in your Selenium browser session, under Firefox with Robotframework - you're "in luck" :). The SeleniumLibrary that comes with it supports starting the browser with a precreted profile - see the documentation, the Open Browser keyword - it has an argument ff_profile_dir.
So create a FF profile with your setting set to the value you need (I don't see a reason why it won't be stored there), and pass its directory as parameter to the Open Browser keyword. Thus when Selenium creates a browser instance, it will use this profile, with that setting effective.

How to open mutiple tabs within a browser using Capybara?

I need to open multiple tabs within a single browser and i need switch over all the tabs.
Give me your suggestions. Thanks in advance.
I'm not so strong in capybara. so, i'm giving solution to switch over between tabs using selenium.
For a instance you clicks a button in a web page and it will open a new page.
The new page may open in a new tab in the same browser window or in a new browser window. That is not controlled by selenium. It will control by the browser which you using.
For a instance take firefox, goto tools->ptions-> tabs-> open new windows in a new tab instead check the option. For example, if you clicks a button it will opens a page only in the new tab of a same browser window. For a sake if you unchecked mean it will open a page in the new browser window. Likewise every browser has its own settings.
Try this code:
new Actions(driver)
.sendKeys(driver.findElement(By.tagName("html")), Keys.CONTROL)
.sendKeys(driver.findElement(By.tagName("html")), Keys.NUMPAD2)
.build().perform();
In above Keys.NUMPAD2 refers that you are gonna move to the second tab in the session.
You can move to Third, Fourth, etc... by giving NUMPAD3, NUMPAD4, etc... respectively. Here i am using windows OS, if you are in some other OS use their shortcuts.
I hope this will help you.
You can use this exact function in Ruby:
page.driver.browser.switch_to.window(page.driver.browser.window_handles.last)

No control to new browser window while swiched to it

In my automation, I have to click on a button which opens a new browser instance with search results, and from that window, I have to select a video to upload. I switched to the window using:
driver.switch_to_window( "File Upload" )
In order to upload a video, I have to select the video from that window, but I can't, as there is no way to access that window. Is there any way in selenium webdriver with Ruby or some other plugin or tool I can achieve this?
The file upload windows are usually system windows and selenium/webdriver cannot be used to interact with it. In Java, sendkeys is used to type the link to the file being uploaded. You can try using an equivalent function (something that you use to type data in any textfield etc function) to directly give the link to your video file.
Hope it helps..

Internet Explorer 8 Restrictions Registry Locations

I'm attempting to restrict IE8 to no toolbars, no anything.
I'm working with Kiosk mode, in Windows XP Home edition.
I have some XP pro computers set up properly with this already, using Group Edit and Windows Steady State.
However, I have been unable to set it up the same way on both XP pro and XP home:
On XP pro, whenever a new window is opened via link, it opens in a small window with no toolbars. In XP home, when a new window is opened via link, it opens a standard browser window, with all the toolbars still there.
I know I can disable the toolbars somehow in the registry, but I have not been able to find where; All the information online that I have seen has not sent me to any existing registry location.
Anyone Help?
As far as I am aware, you can start IE in kiosk mode from the cmd line - by running iexplore -k followed by the web address you want to open. If the registry values that you need to use to lock down the browser aren't there, you can just create them.
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet Explorer\Restrictions
Create them as DWORD values - with a value of 1 enforcing the policy.
NoBrowserClose (disables closing the browser window)
NoBrowserContextMenu (disables right-click context menu)
NoFileOpen (disables use of Ctrl-O or Ctrl-L to launch an arbitrary URL)
NoOpenInNewWnd (disables opening a link in a new window via Ctrl-N or Shift-click)
These should pretty much cover all of the normal ways a user could circumvent kiosk mode.
In addition to the above, there are also:
AlwaysPromptWhenDownload - Always prompt user when downloading files.
NoBrowserBars - Disable changes to browsers bars.
NoBrowserClose - Disable the option of closing Internet Explorer.
NoBrowserContextMenu - Disable right-click context menu.
NoBrowserOptions - Disable the Tools > Internet Options menu.
NoBrowserSaveAs - Disable the ability to Save As.
NoFavorites - Disable the Favorites.
NoFileNew - Disable the File > New command.
NoFileOpen - Disable the File > Open command.
NoFindFiles - Disable the Find Files command.
NoNavButtons - Disables the Forward and Back navigation buttons
NoOpeninNewWnd - Disable Open in New Window option.
NoPrinting - Remove Print and Print Preview from the File menu.
NoSelectDownloadDir - Disable the option of selecting a download directory.
NoTheaterMode - Disable the Full Screen view option.
NoViewSource - Disable the ability to view the page source HTML.
RestGoMenu - Remove Mail and News menu item.

Avoid opening command history window while running selenium rc

I am new to Selenium. Whenever I run the selenium script to open the browser, it additionally opens a selenium console window with the command history.Is there any way of suppressing the browser from opening this window?
I don't know if it possible to avoid presentation of the command history, but if you want to avoid opening additional window with logs, run Selenium RC with -singleWindow parameter.
java -jar path/to/server/selenium-server-standalone.jar -singleWindow

Resources