I'm working on following scenario with WebDriver Sampler in Jmeter on javascript:
perform several requests in main window;
for 1 specific transaction:
2.1. - switch from initial window to newly created window (both windows have the same title),
2.2. - allow mic and cam (browser dialog box appears after new window is open and blocks activity of some page elements until cam and mic will not be allowed),
2.3. - find elements on page and perform actions with them (I wrote javascript snippets for that),
2.4. - close this 2nd window;
return back to initial main window;
proceed with requests in main window.
For steps 1 and 4 I have in js code all I need.
For step3, I suppose to use solution:
//switch back to initial main window:
WDS.browser.switchTo().defaultContent();
But I'm still stack on 2.1 and 2.2.
What is the best solution with 2.1, 2.2 and 2.4?
For 2.2. I tried to use "Set Preferences" section in Firefox WebDriver config and populate it with following:
Disadvantages: 1st - unfortunatelly, it doesn't work, and 2nd - I need these preferences working with Chrome, not only in FF.
Could you provide helpful tips, please, with 2.1, 2.2, 2.4?
I don't think this modal popup is a "window" controllable by WebDriver, it's rather a native window of the operating system hence you won't be able to interact with it using WebDriver functions, the options are in:
Simulate keyboard inputs using java.awt.Robot class
Locating the window using underlying operating system methods and sending the corresponding message to it, the entry point is JNI
Suppress these popups on browser startup level:
for Firefox you can load a custom profile with camera and mic allowed for the site you're testing
for Chromium and derivatives you can set the following ChromeOptions
use-fake-ui-for-media-stream
use-fake-device-for-media-stream
Unfortunately both approaches are not available out of the box for the Firefox Driver Config and Chrome Driver Config so you will have to switch to JSR223 Sampler and Groovy language for implementing your test scenario