SSLConnectionSocketFactory error in JMeter and WebDriver Set - selenium

I've encountered problems with starting JMeter and WebDriver Set.
I set - Thread Group with:
jp#gc FF Driver Config
jp#gc Web Driver Sampler
View Results in Table
In Web Driver Sampler I have following lines:
WDS.sampleResult.sampleStart()
WDS.browser.get('http://google.com')
WDS.sampleResult.sampleEnd()
And I get following error:
ERROR - jmeter.threads.JMeterThread: Test failed! java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.conn.ssl.SSLConnectionSocketFactory
How can I make it work?

Make sure you use the latest JMeter version (2.13 as for the moment)
Make sure you use the latest WebDriver Set plugin package (1.3.1 as for now)
Make sure you use supported Firefox version
Supports native events for Firefox version 31 (immediately previous ESR).
Native event support has been discontinued for versions of Firefox later
than 33. Synthetic events tested on Firefox versions 31 (immediately
previous ESR), 38 (immediately previous release and current ESR), and 39
(current release).
Before starting JMeter:
go to JMeter's /lib folder
locate .jar files which names start with "http"
delete files which have lesser versions
If you still experience problems check out The WebDriver Sampler: Your Top 10 Questions Answered guide

Related

The method attachToEdgeChrome() is undefined for the type InternetExplorerOptions using selenium-server-4.0.0-alpha-2

I want test the IE mode for Edge browser with Selenium. I found the solution on the MS site here:
https://learn.microsoft.com/en-us/microsoft-edge/webdriver-chromium/ie-mode?tabs=java
I am using the following code as given in the above link:
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerOptions;
InternetExplorerOptions ieOptions = new InternetExplorerOptions();
ieOptions.attachToEdgeChrome();
ieOptions.withEdgeExecutablePath("C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe");
WebDriver driver = new InternetExplorerDriver(ieOptions);
I can get the error that the methods "attachToEdgeChrome()" and "withEdgeExecutablePath()" are not defined in the InternetExplorerOptions. Is there anything I am missing here?
Note: My selenium jar is selenium-server-4.0.0-alpha-2.jar
As per the ChangeLogs 0f Selenium v4.0.0.0-alpha-2:
Add Chromium-based Edge support. This involves adding a new Chromium driver to the tree too.
So ideally, the code block from the documentation Use Internet Explorer Driver to automate IE mode in Microsoft Edge should have worked seamlessly.
However, as per best practices instead of using the alpha and beta releases, you should always prefer the GA releases to execute your tests and you can pickup anyone from the following options:
Selenium v4.1.3
Selenium v4.1.2
Selenium v4.1.1
Selenium v4.1.0
Selenium v4.0.0

"Component not initialized" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" error with Selenium GeckoDriver and Mozilla

I am trying to execute my code in Firefox, sometimes it works but majority of time i get exception as:
[Exception... "Component not initialized" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: chrome://marionette/content/dom.js :: addEventListener :: line 67" data: no]
Its happening from last week, previously it was working fine for me.
NS_ERROR_NOT_INITIALIZED resembles an attempt which was made to use a component or object which has not yet been initialized. These components usually provide an initialization method, often called Init which must be called before any other methods which are being used.
However, this error message...
[Exception... "Component not initialized" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: chrome://marionette/content/dom.js :: addEventListener :: line 67" data: no]
...implies that the Marionette threw an error while invoking addEventListener as defined in dom.js
Your code trials and the relevant HTML DOM would have helped us to debug the issue in a better way. However it seems the addEventListener was invoked too early even before the DOM Tree was completely rendered. To be more specific addEventListener was invoked even before the Browser Client (i.e. the Web Browser) have attained 'document.readyState' equal to "complete". Generally once this condition is fulfilled Selenium performs the next line of code.
Solution
A quick solution will be to before you try to interact with any of the element on a fresh loaded webpage you need to induce WebDriverWait for either of the following expected_conditions:
title_is(title)
title_contains(title)
An example
Python:
Code Block:
driver.get("https://stackoverflow.com");
WebDriverWait(driver, 10).until(EC.title_contains("Stack"))
print("Page Title is : "+driver.title)
Console Output:
Page Title is : Stack Overflow - Where Developers Learn, Share, & Build Careers
Java:
Code Block:
driver.get("https://stackoverflow.com");
new WebDriverWait(driver, 10).until(ExpectedConditions.titleContains("Stack"));
System.out.println("Page Title is : "+driver.getTitle());
Console Output:
Page Title is : Stack Overflow - Where Developers Learn, Share, & Build Careers
Additional Considerations
Upgrade JDK to recent levels JDK 8u221.
Upgrade Selenium to current levels Version 3.141.59.
Upgrade GeckoDriver to GeckoDriver v0.25.0 level.
Ensure that the version of the binaries you are using are compatable.
You can find a detailed discussion in Which Firefox browser versions supported for given Geckodriver version?
GeckoDriver is present in the desired location.
GeckoDriver is having executable permission for non-root users.
Upgrade Firefox version to Firefox v69.0 levels.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your Test as a non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
References
You can find a couple of relevant discussions in:
WebDriverException: Message: Exception… “Failure” nsresult: “0x80004005 (NS_ERROR_FAILURE)” while saving a large html file using Selenium Python
[org.openqa.selenium.WebDriverException: Exception… “Component not initialized” error using GeckoDriver and Tor browser with Selenium Java
Outro
Occur the 'NS_ERROR_NOT_INITIALIZED' when switching the window to bottom dock.
It seems you're suffering from Geckodriver Issue 1263, you can try the following workarounds:
Update Selenium client library to the latest stable which is 3.141.59 as of now, it's better to use package management system like Maven or Gradle as update of dependencies libraries might be required. If you're not using Java check out Web - Desktop and Mobile Browsers article for code examples for different Selenium client languages like JavaScript, Python, C#, etc.
Make sure to use the latest version of Firefox
Make sure to use the latest version of Geckodriver
If you will be still experiencing problems you can consider raising a new issue in the Geckodriver project, be prepared to provide as much information as possible (the same applies to next questions here if any)
On my case, some configs were wrong. I was trying to block pop-up downloads, but something went wrong.Here is the code that I had to remove, and it worked (on this specific case):
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.dir", "C:\\Temp");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "text/csv");
profile.setPreference("pdfjs.disabled", true);
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.panel.shown", false);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
capabilities.setCapability(CapabilityType.ELEMENT_SCROLL_BEHAVIOR, 1);
driver = new FirefoxDriver(capabilities);

Chrome failed to start - Chrome version 75.0.3770.100

We have selenium tests in C# running on jenkins. With the latest version of Chrome 75 the tests are starting to fail during execution with the error "Chrome failed to start"
I went through some articles and have implemented the below code as part of my arguments for Chrome.
chromeOptions.AddArgument("--enable-automation");
chromeOptions.AddArgument("--no-sandbox");
chromeOptions.AddArgument("--disable-extensions");
chromeOptions.AddArgument("--disable-print-preview");
chromeOptions.AddArgument("--disable-gpu");
chromeOptions.AddArgument("--disable-software-rasterizer");
chromeOptions.AddArgument("--disable-gpu-sandbox");
chromeOptions.AddArgument("--disable-features=VizDisplayCompositor");
chromeOptions.AddArgument("--start-maximized");
chromeOptions.AddArgument("--disable-dev-shm-usage");
chromeOptions.PageLoadStrategy = PageLoadStrategy.Normal;
This happens during jenkins execution only.
I'm seeing this on Chrome 76. The solution seems to be to remove the --disable-software-rasterizer argument.

Unable to launch URL in edge browser - Selenium Java

I am trying to automate in Microsoft edge browser. I referred to the below links to do it and I am able to launch the browser, but it's failing to launch the URL. Can someone please help me.
Selenium Java version : 2.53.1
Tried with both of the edge drivers(insider version and webdriver), one returned null exception and not launching any browser and the other is returning unknown error after launching the browser.
https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Code referred from:
stackoverflow.com/questions/31991309/selenium-on-windows-10-edge-browser
You would need to download the correct version of Edge Driver based on the OS build number. I faced this issue when I used Edge driver version which was different from my build number.
Follow the below steps (I have tried this with Selenium 3.0 Beta1 and its working fine)
Use the steps given below -
Go to Start > Settings > System > About and note down the OS Build number
Download the proper version of the driver from this link - https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
If the file that's downloaded is .msi, then install it to get the .exe driver. For one of the release, direct .exe can be downloaded.
Once the MicrosoftWebDriver.exe is downloaded, we can use it in our test script using either System.setProperty("webdriver.edge.driver", "driver location") or using environment variable
Sample Script :
System.setProperty("webdriver.edge.driver","C:\\Program Files (x86)\\Microsoft Web Driver\\MicrosoftWebDriver.exe"); //put actual location
WebDriver driver = new EdgeDriver();
driver.get("your link");
Refer this article for detailed information: http://automationtestinghub.com/selenium-3-launch-microsoft-edge-with-microsoftwebdriver/
Note : Edge browser version should be 18 or 19
This solution worked for me was by enabling Developer Mode in Windows OS:
Go to Settings -> Windows Update settings ->For Developers -> Enable Developer Mode
Run Test Script :
public class IETest {
public static void main(String[] args)
{`enter code here`
WebDriver obj=new EdgeDriver();;
obj.navigate().to("http://www.google.com");
}
}

Selenium Webdriver + Protractor + CucumberJS

Hello All
I've discovered an issues, which I'm not sure it really is an known issue with the framework or it's due to the versions of Protractor + CucumberJS that I am using, these are:
"cucumber": "~0.7.0",
"protractor": "~2.5.1",
"selenium-standalone": "3.0.0",
I'm using this versions as of today, I know that CucumberJS was separate from Protractor, but since our current project is using Node < 4, I cannot update it.
Having said this, the error that I'm having is when I run the test suite with protractor config.js and the seleniumAddress attribute commented (it starts up a webdriver automatically at random port)
The error that appears, when the suite finishes is:
throw new Error('This driver instance does not have a valid session ID ' +
^
BUT when I run the exact same suite, starting webdriver manually and setting the selenium address, the test passes!!!
The suite contains:
17 scenarios (17 passed)
55 steps (55 passed)
Does anyone knows what could be the reason? My first thought is that starting the server manually it would make webDriver slower, and therefore test actions would be too, so... but I had compared both time executions and there's only 1 second difference between both....
I had realized, that the problem with all is that since I had commented out the seleniumAddress line, Protractor was starting up webDriber-manager automatically, and when I added the line and manually started WebDriver, the error did not happen again. NOT sure what's the matter with it starting up automatically but, in case you ran into the same problem here's the solution!
Thanks