Need help about webrtc performance test with Selenium and Jmeter (Java) - java

I am trying to automate test to webrtc application and I'm trying to do it with multiple users. I created a setUp as below.
`
ArrayList<String> prefs = new ArrayList<String>();
prefs.add("--use-fake-device-for-media-stream");
prefs.add("--use-fake-ui-for-media-stream");
System.setProperty("webdriver.chrome.driver", "C:\\....\\resources\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments(prefs);
driver = new ChromeDriver(options);
driver.get("https://......");`
but when I use "--use-fake-ui-for-media-stream", the following remote address appears in the logs of the media server of the app.(I used this to disable the security popup for camera and mic.)
remote address looks like: 79beeb9e-ff01-4e69-906c-5be9cab979e6
when I don't use it, the remote address looks like this: 172.17.x.x
Therefore, I cannot connect to the meeting room, the server refuses the remote address.
When I remove "--use-fake-ui-for-media-stream" and put "--user-data-dir=C:\Users....\Local\Temp\...", I overcome this problem, but this time I can only connect to a single chromedriver on the Jmeter, the other chromedrivers are not working. I integrated testcases to Jmeter with Junit request.
I want to use this code for multiple users but I only could do it for a user or I could not connected.
How can i overcome this problem?

When first ChromeDriver instance is launched the profile directory gets locked and it cannot be re-used by 2nd, 3rd, etc. instance.
You can do something like:
prefs.add("--profile-directory=User" + org.apache.jmeter.threads.JMeterContextService.getContext().getThreadNum());
so each instance will have it's own separate profile folder.
More information:
open multiple chrome profile with selenium
JMeterContextService JavaDoc
How to Use JUnit With JMeter

Related

Selenium Basic Authentication via URL HeadlessChrome ( On Linux Server)

In my Selenium Tests I need to test a webpage where I use a basic Authen,
Knowing that I am using Chrome Headless Java and Selenium WebDriver.
On my machine 'locally' It works perfectly using driver.get("https://admin:admin#localhost..");
and then
driver.get("https://localhost..") for example.
I know that Chrome doesn't support this function anymore but I managed to make it work based on someone's solution here by passing the first URL with credentials and the second without.
But when I run it on remote (Jenkins) On Linux servers I get the following Error
the configuration of your browser does not accept cookies
. I don't have vision on the servers when I can configure Chrome ..any ideas how to make it work without facing that problem.
I know a lot of people asked that question before, But I didn't find any valide answer for my issue.
try ChromeDriver 2.45 (changelog) or change the location, where it is supposed to save the cookies:
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=/path/to/your/custom/profile");
otherwise (per default) it would create a new temporary directory each time it starts a session.
ChromeOptions options = new ChromeOptions();
//Command line flag for enabling account consistency. The default mode is disabled.
options.addArguments("--account-consistency");
//Chrome that will start logging to a file from startup
options.addArguments("--log-net-log=C:/some_path/resource/log.json");
//Sets the granularity of events to capture in the network log.
options.addArguments("--net-log-capture-mode=IncludeCookiesAndCredentials");
Try this, basically, it saves the logs on startup of chrome browser, then it will set the account consistency. Anywhere from the log, you can debug the issue.
Hello I managed to fix the problem (I forgot to mention that our website is protected by Siteminder) so I did the following following:
1-We inject the USER and the PASSWORD on the URL :
The issue we faced was that the displayed prompt wasn’t part of the page’s HTML and it was hard for us to catch it using Selenium. We managed this by directly injecting the user login and the user password in the URL as follow :
‘https://USERNAME:PASSWORD#basicAuthentURL’
This will launch the Chrome session. Beware, this is only the first step of the process. The user identification have not been performed yet.
2- We create a new cookie :
After launching the URL, we have to manually create a cookie called « SMCHALLENGE » and add it to current session with Selenium, for example in JAVA :
new Cookie("SMCHALLENGE", "YES");
3- Call the URL without the user credencials :
As the SMCHALLENGE cookie is now set, the last step is to call the URL again (https://basicAuthentURL ). The SMCHALLENGE cookie will be deleted once the authentication succeed and a SMSESSION cookie will be generated by Siteminder.
The SMSESSION cookie now allows us to call the application and sucessfully pass Siteminder as if normally logged in (via SSO).
Let me know if you try this out.

Unable to sendkeys/click with selenium Java or JavascriptExecutor

These are the steps that my code is running.
I start the chromedriver with the secure shell appt - no issues, it launches the browser and appt correctly
chromeOptions.addExtensions(new File("src/test/resources/win32/browserprofile/Secure-Shell-App_v0.8.43.crx"));
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
I then navigate using driver get to the chrome URL setup page to send connection data.
driver.get("chrome-extension://pnhechapfaindjhompbnflcldabbghjo/html/nassh.html");
While on this page from the image below, I tried to send keys or click on any of the fields with sendkeys or click and I get the following error.
I have tried multiple ways and im getting the same results: org.openqa.selenium.WebDriverException: unknown error: Cannot set property 'value' of null
Here is my code
//Webdriver
driver.findElement(By.xpath("//*[#id='field-description']")).sendKeys("aabb");
driver.findElement(By.id("field-username")).click();
driver.findElement(By.id("field-username")).sendKeys("useridval");
driver.findElement(By.id("field-hostname")).click();
driver.findElement(By.id("field-hostname")).sendKeys("10.0.0.0");
//JavascriptExecutor
// This will execute JavaScript in your script
((JavascriptExecutor)driver).executeScript("document.getElementById('field-username').value='migsrcrfuser';");
Question: Is this even possible, I see an id and the id is unique; furthermore, I also tried xpath and received the same result. Thoughts
Breift description: Terminal emulator and SSH client.
Secure Shell is an xterm-compatible terminal emulator and stand-alone ssh client for Chrome. It uses Native-Client to connect directly to ssh servers without the need for external proxies.
https://chrome.google.com/webstore/detail/secure-shell-extension/iodihamcpbpeioajjeobimgagajmlibd
Update your ChromeDriver to 2.37 (the latest) from https://sites.google.com/a/chromium.org/chromedriver/downloads
I think that you are using Chrome v65
The issue was frame related. I used this code to identified how many frames and then send keys to the correct frame. phew!
int size = driver.findElements(By.tagName("iframe")).size();
System.out.println(size);
driver.switchTo().frame(1); // Switching the inner Frame with 1 0 for outer fram
driver.findElement(By.xpath("//*[#id='field-description']")).sendKeys("9109");

Browser Stack | Selenium Webdriver | Handling Windows host file enteries

I have Hybrid Framework using Selenium Webdriver that successfully executes test cases against Firefox, Chrome and IE. Now, I wanted to run this entire suite using Browserstack.
However, when I try to access the application I make entries in the host file - the ipaddress and the host name. This makes sure that I'm hitting the exact server.
Using Java code on https://www.browserstack.com/automate/java I'm able to execute a sample script.
However, how can I pass the ipaddress mapping of my application to my Selenium instance when executing it on Browserstack?
The BrowserStack Local Testing feature (https://www.browserstack.com/local-testing) should help you test your private servers configured in your hosts file. Please follow these steps:
1) Download and execute the Local Testing binaries (https://www.browserstack.com/local-testing#command-line) using the following command:
./BrowserStackLocal ACCESS_KEY -forcelocal
The '-forcelocal' parameter will route all traffic via your machine which allows you to test servers configured in your hosts file on BrowserStack.
2) Add the capability 'browserstack.local'='true' in your test scripts and execute them.

Unable to clear Browser cookies and Session Data with Selenium

I have been using Java Selenium WebDriver along with Appium to perform tests on Mobile environment be it Emulator(Genymotion) or Physical devices (Android). I am using chromedriver, which I am using to perform tests on Web App in Chrome browser. I am looping my cases for multiple sets of data but the application requires a full browser Cookie and all Session data to be deleted before each loop starts.
I tried using driver.Manage().Deleteallcookies(), but it did not work out for me. I read in some threads to try creating a new session of the browser before each loop. So I tried driver.quit() but it ends the chromedriver session and ends the test. I also tried driver.close() but got the same results as driver.quit().
Can any one suggest a way to delete the browser cookies and session data in chrome browser??
My Appium version:1.3.4.1
Chromedriver version:2.3
Device/Emulator i am trying to test on : Nexus5/Samsung Note 3 Android:4.4.4/5.0
You can try using the following to ensure a clear session. Note I never tested that myself. My understanding is that selenium by default create a new session unless you specified something different or load a profile.
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
ChromeDriver driver = new ChromeDriver(capabilities);

Using Personal SSL certificates with Webdriver (Selenium 2.0)

I am testing a website which requires personal SSL certificates in order to do certain things, such as sign-in.
I have a Webdriver (Selenium 2.0) test that I have set up with a proxy:
Proxy localhostProxy = new Proxy();
localhostProxy.setProxyType(Proxy.ProxyType.MANUAL);
localhostProxy.setHttpProxy("www-proxyname:port");
FirefoxProfile profile = new FirefoxProfile();
profile.setProxyPreferences(localhostProxy);
driver = new FirefoxDriver(profile);
And this will access the homepage fine. The test then clicks the sign in button, enters in the correct credentials and clicks on submit. At this point the browser then goes into a loading state, and I'm assuming it's because the SSL certificate is missing from my side and therefore cannot connect to the sign in service.
I searched for different proxy solutions, and found this:
profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(true);
So I added it into my code, but it doesn't seem to do what I want. I think I'm looking for a way to tell WebDriver that my ssl certificate is in x directory, please use it when accessing this site. Does anyone know how to do this?
My Test code is:
#Test
public void userSignsInAndVerifiesDrawerViews(){
driver.get("www.url.com");
waitFor(5000);
driver.findElement(By.xpath("//a[contains(text(), 'Sign in')]")).click();
waitFor(3000);
String username = "seleniumtest";
String password = "seleniumtest1";
driver.findElement(By.id("username")).sendKeys(username);
driver.findElement(By.id("password")).sendKeys(password);
driver.findElement(By.xpath("//signin")).click();
waitFor(30000);
String signInLinkText = driver.findElement(By.xpath("//xpath")).getText();
assertEquals(signInLinkText, username);
}
Webdriver has no built in mechanism for adding a personal cert.
If you are using firefox the only way that I have found to do this is to create a firefox profile and add the certificate to it. You can then either reuse the profile when you run your tests OR, and this is my prefered option, take the cert8.db and key3.db files and add them to the profile that webdriver creates at runtime.
I am not sure how yo do this in java, but in ruby I override the layout_on_disk method of FirefoxProfile to add the extra files I required. Java has the same class so you should be able to do this same thing.
No need to overwrite the method layout_on_disk() as suggested.
You can simply load as profile a folder containing the files cert8.db and key3.db.
Selenium will complete the profile for you.
Then you can add the preferences you need to the firefox profile.
The resulting code looks like this:
FirefoxProfile firefoxProfile = new FirefoxProfile(
new File("/folder/location"));
FirefoxOptions options = new FirefoxOptions();
options.setProfile(firefoxProfile);
WebDriver driver = new RemoteWebDriver(
new URL("http://localhost:4444/wd/hub"),
options.toCapabilities());
Tested with selenium 3.5.3.
Webdriver can do this, although Derek is right and it isn't built in.
All you need to do is make a custom Trust Manager that trusts all certs and then also override the "hostname verifier" to allow a non-real domain name.
There is somewhat of an example I found on Google here:
http://grepcode.com/file/repo1.maven.org/maven2/org.seleniumhq.selenium.server/selenium-server-coreless/1.0.3/org/openqa/selenium/server/TrustEverythingSSLTrustManager.java
This is the same method you would use with Apache HC components to override SSL settings without using WebDriver. I've used this method a lot with direct HTTP posts using Apache HT components and it "appears" that from the link above , this concept should also work with WebDriver.

Categories

Resources