How to manage web drivers via jenkins - jmeter webdriver script? - performance

I have to build JMeter script using JSR223 Sample for chrome, I was wondering if there is a way that I can configure path in the script so that I don't need to host drivers in Jenkins.
In Selenium Automation, I used webdriverManger to download new driver every time https://www.toolsqa.com/selenium-webdriver/webdrivermanager/
JSR223 Sampler:
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.support.ui.WebDriverWait;
**System.setProperty("webdriver.gecko.driver","/Users/geckodriver");**
FirefoxOptions options = new FirefoxOptions().setAcceptInsecureCerts(true);
WebDriver driver = new FirefoxDriver(options);
def wait = new WebDriverWait(driver, 20);
driver.get('https://google.com/');
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(".//input[#name='q']")));

You can do the same in JMeter:
Download WebDriverManager "fat" jar from the releases page and drop it to "lib" folder of your JMeter installation or at any other place in JMeter Classpath
Restart JMeter to pick the .jar up
Replace your
**System.setProperty("webdriver.gecko.driver","/Users/geckodriver");**
with
io.github.bonigarcia.wdm.WebDriverManager.firefoxdriver().setup()
Enjoy
More information and another trick you can play: How to Reuse Your JMeter Code with JAR Files and Save Time

Related

I added the relaevant jar files in lib folder of jmeter and also added jar files in "Add directory or jar to classpath" but getting issues shown below

2020-03-19 10:28:54,395 WARN o.a.j.e.BeanShellPostProcessor: Problem in BeanShell script: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import java.io.*; import java.util.*; import org.json.JSONObject; import org.jso . . . ''
2020-03-19 10:29:54,532 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import java.io.*; import java.util.*; import org.json.JSONObject; import org.jso . . . '' : Typed variable declaration : Class: JSONParser not found in namespace
I added the relaevant jar files in lib folder of jmeter and also added jar files in “Add directory or jar to classpath” but getting issues shown below
You need to restart JMeter to pick up the .jar files you added to JMeter Classpath
Since JMeter 3.1 you should be using JSR223 Test Elements and Groovy language for scripting so consider migrating to JSR223 PostProcessor. Moreover Groovy has built-in JSON support so most probably you won't need these extra libraries at all. See Apache Groovy - Why and How You Should Use It article for more details.

Not able to import "org.openqa.selenium.chrome.ChromeDriver" on MacOS

I was writing a java program for selenium when tried to import "org.openqa.selenium.chrome.ChromeDriver" but it gives an error.
"The import org.openqa cannot be resolved" on my MacBook.
import org.openqa.selenium.chrome.ChromeDriver;
public class Login {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "/Users/shilpa/Documents/Selenium/Selenium Softwares/chromedriver.exe");
WebDriver driver = new ChromeDriver();
}
This error message...
The import org.openqa cannot be resolved
...implies that ChromeDriver wasn't resolved at compiletime.
There can be a lot many resons behind this error. A bit more about your Test Environment e.g. JAR files, Maven or Gradle and the binary versions would have helped us to debug the issue in a better way. You can find a couple of relevant discussions in ChromeDriver and WebDriver for Selenium through TestNG results in 4 errors and java.lang.Error: Unresolved compilation problems : WebDriver/ChromeDriver cannot be resolved to a type error while executing selenium tests
Morepver, as you are using MacOS you instead of using the chromedriver.exe from chromedriver_win32.zip you need to download, extract and use the chromedriver binary from chromedriver_mac64 and change the System.setProperty() line as follows:
//without the extension (.exe)
System.setProperty("webdriver.chrome.driver", "/Users/shilpa/Documents/Selenium/Selenium Softwares/chromedriver");

Java 8 and Cucumber don't run the step files with lambdas methods

I have a great problem and I have tried to solve this problem, but all time is the same.
I have this scenario with cucumber
feature file
And this is the steps' file
steps' file
Finally I run with
package Steps;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
#RunWith(Cucumber.class)
#CucumberOptions(
features = {"./src/test/java/features"},
glue = {"./src/test/java/Steps"},
plugin = {"pretty", "html:reports/cucumber-html-report","json:cucumber.json"}
)
public class Orquestador {
}
And the consolo of intellij appear this:
ans
these are all my files
Files
I am using Mac OS
Thanks :)
Cucumber is not finding your step definitions. Provide the correct "glue" to the location of your step definitions when running the feature file.

jmeter Error when changing to java or groovy

I am using the and I get error
import package is not defined at line 2
when switching to groovy or java. I am using version 3.1 jmeter and java version 1.8.0.
the sampler is jp#jc
Line 2 is
import java.io.File;
I am tried moving down to java1.7 but this does not work either

Missing IBM Websphere classes for SSO (com.ibm.jca.idtoken)

I am trying to enable SSO on a WAS 8.5, which is installed on an AS400, and for this I need to use the following classes in java:
import com.ibm.eim.token.IdentityToken;
import com.ibm.jca.idtoken.ConnectionFactoryImpl;
import com.ibm.jca.idtoken.ConnectionSpecImpl;
import com.ibm.jca.idtoken.IdentityTokenFactory;
I found the package com.ibm.eim in \QIBM\ProdData\OS400\security\eim on the WAS server. However, I cannot find the package com.ibm.jca.idtoken in the file system nor on the IBM Knowledge Center website either. Where can I get it ?
Okay I finally found it. It is here in a jar in a jar in a rar file :
com.ibm.jca.idtoken:
\QIBM\ProdData\OS400\security\eim\idTokenRA.rar\idTokenRA.jar\com\ibm\jca\idtoken\
com.ibm.eim.token:
\QIBM\ProdData\OS400\security\eim\idTokenRA.rar\idToken.jar\com\ibm\eim\token\

Resources