I'm trying to test a scenario where two separate users are logged in. As the question states, is this possible with Selenium? I don't if it's browser dependent, but I'm using Chrome.
Selenium (web driver) allows to open several browser windows (e.g. 3 Firefox windows or 1 IE + 1 Firefox +1 Chrome).
In you code you have API to select the desired window (depending how on how you opened it).
Regarding the session handling: that depends on the browser type. Firefox will share the session across multiple windows because it's using a single process. AFAIK IE and Chrome if opened as new processes will not share it, but this of course depends also on how the server is setting the cookie policy for the session.
Access to cookie values in the browser however is domain dependent, so a persistent cookies or local storage can share information even across sessions, so it really depends on how the web application is implemented (or what framework is using - that mostly takes care of such stuff).
If you want complete separation, then take a look at Selenium Grid;https://code.google.com/p/selenium/wiki/Grid2
This would allow you to have the browsers open on different computers while running the test on one machine
Related
When 2 tests are running in Chrome, i have observed that too many Google Chrome(32 Bit) processes are running in Task manager, Is this a correct behavior of Chome Driver
When multiple automated tests are getting executed through Google Chrome you must have observed that there are potentially dozens of Google Chrome processes running which can be observed through Windows Task Manager's Processes tab.
Snapshot:
As per the article SOLVED: Why Google Chrome Has So Many Processes for a better user experience Google Chrome initiates a lot of windows background processes for each tab that have been opened by your Automated Tests. Google tries to keep the browser stable by separating each web page into as many processes as it deems fit to ensure that if one process fails on a page, that particular process(es) can be terminated or refreshed without needing to kill or refresh the entire page.
However, from 2018 onwards Google Chrome was actually redesigned to create a new process for each of the following entities:
Tab
HTML/ASP text on the page
Plugin those are loaded
App those are loaded
Frames within the page
In a Chromium Blog Multi-process Architecture it is mentioned:
Google Chrome takes advantage of these properties and puts web apps and plug-ins in separate processes from the browser itself. This means that a rendering engine crash in one web app won't affect the browser or other web apps. It means the OS can run web apps in parallel to increase their responsiveness, and it means the browser itself won't lock up if a particular web app or plug-in stops responding. It also means we can run the rendering engine processes in a restrictive sandbox that helps limit the damage if an exploit does occur.
As a conclusion, the many processes you are seeing is pretty much in line with the current implementation of google-chrome
Outro
You can find a relevant discussion in How to quit all the Firefox processes which gets initiated through GeckoDriver and Selenium using Python
I was asked a question :
Assume I have 4 machines and I need to execute a script in all the machines across all the browsers. How will I achieve that.
I told him the concept of Selenium Grid, where in we could set up a machine which acts like a hub, configure 3 more machines which would act like a node.
Using Desired Capabilities among others we could choose a browser type and version type in that and write a script.
But he asked me two things :
IN all the node machines how do you configure the Windows username and Password if the machine is locked. Can you write windows Authentication in the script.
Can I achieve testing different browser versions of same browser type in a single node?
Can I pass as a the browser type and browser version as a parameter
from hub to the node?
Can someone throw some light on these as I was unable to answer. Thanks.
Question 1: Is it really necessary for the machine to be unlocked for the test to start? The selenium node is a background process that listens for commands, and executes them on the browser, so I do not think this is necessary. If it is necessary due to your specific windows settings however, then no, you cannot do this from the selenium script obviously.
Question 2: Yes, you can test different browser versions of the same type on the same node. You can pass the browser name and version to the node. However, keep in mind that the node cannot know the location of the different browser versions, so you will also have to supply the path to the browser executable for your requested version
I'm testing a website which uses cookies for security. Every time a user logs in with a different device or browser they must go through an intensive (email and phone keys) identity verification process. My backup/restore process uses a Firefox addon and works for manual testing.
However when I run Selenium I get triggered to go through the ID process every time. So either Selenium is not using the cookies, or is being given a different browser ID for some reason.
I set a breakpoint to check my cookies are loaded in the Selenium Firefox browser window, but my addon is not available in Selenium Firefox instances.
Selenium documentation is very slim on cookie use:
http://www.seleniumhq.org/docs/03_webdriver.jsp
So any info much appreciated.
I'm building a distributed system with websockets. Browser clients can connect to each other directly or to a central server. I would like to test a few distributed use cases end-to-end.
Example 1:
Open Browser A and connect to my site
Open Browser B and connect to my site
Browser A sends a chat message to Browser B
Confirm that Browser B received the message
Example 2:
Open Browser A and connect to my site
Open Browser B and connect to my site
Browser A sends a chat message to Browser B
On Browser B, a "disconnect" button is clicked
Confirm that Browser B does not receive the message
On Browser B, a "reconnect" button is clicked
Confirm that Browser A received the message
How can I do this? I've seen selenium running in parallel, but I haven't seen anything that allows you to coordinate the interaction between browsers.
Your test can open many webdriver instances.
If you open 2 instances in your test, one can represent browser A and the other browser B.
Call methods on these objects to simulate the scenario you discuss in your post.
To achieve this you need to use RemoteWebDriver. If all hosted locally, you will get two unconnected browsers on your computer. If you use a Grid, then you will get 2 browsers somewhere on your grid, probably on different machines.
If you want complete control, you could just start Selenium instances on two remote machines and use these hard coded machine names for A and B. In this scenario there would be no Grid.
Word of warning though. If you try to host all browsers locally, you cannot use IE as multiple IE all share common data where as Chrome are completely separate
I'm in search of a method to test multiple roles of an application with a browser. For this question, I need solutions for interactive operation, user assumed to being signed-in.
Target OS would be primarily OS X, but please provide Windows solutions too.
All browsers I'm aware of, store cookies centralized in a browser. If I'm signed-in to a web-app with say role A and then sign-in as role B, role A gets hidden - because most web-apps share a single session token, which identifies user's role.
Do solutions exist, to test two roles in parallel in a browser? A browser, which has different separated identities?
Due to certain reasons, opening two different browsers wouldn't be an option.
Since you're on a Mac, you can use open -n /Applications/BrowserName.app for whichever browser you want (though newer versions of Firefox apparently require slightly more work: https://superuser.com/questions/396434/how-to-open-a-new-firefox-window-with-terminal). This command will open an entirely new instance of the browser each time you run it.
Depending on how you're testing, you may want to clear cookies on browser close, though cookies shouldn't interfere while the browsers are running. (Not tested.)
Just found this:
Firefox has a feature named Profiles. Using Firefox' command line arguments, one can create multiple separated profiles:
E.g. on OS X, the Firefox' Profile Manager opens using this command:
/Applications/Firefox.app/Contents/MacOS/firefox-bin -ProfileManager
To have two different Firefox instances run with different profiles on OS X, one needs to create a copy of the Firefox application.
Still, I'd be happy to learn of solutions for other browsers. Or integrated solution, which doesn't force me to copy the browser app.