Execute Selenium tests with Selenic and API tests with SOAtest at the same time
Selenium tests execute from the command line or the IDE. SOAtest tests also execute from the command line or from SOAtest. So you could execute them both from the commandline together. There are many ways to do this, like from Jenkins. Here is an example script:
AGENT_DIR=<PATH TO SELENIC JARS> WEBDRIVER_DIR=<PATH TO WEBDRIVER> SELENIUM_WORKSPACE=<PATH TO SELENIUM WORKSPACE> SELENIUM_PROJECT=<PATH TO SELENIUM PROJECT> //com.parasoft.webdriver.parabank.junit SELENIUM_TEST=<PATH TO SELENIUM TEST> //ParabankDemoTest SOATEST_HOME=<PATH TO SOATEST> SOATEST_WORKSPACE=<PATH TO SOATEST WORKSPACE> SOATEST_TEST=<PATH TO SOATEST TEST> //mytest.tst REPORT=<PATH TO REPORTS> //First Execute Selenium Tests cd $SELENIUM_WORKSPACE mvn surefire:test \ -pl $SELENIUM_PROJECT \ -Dtest=$SELENIUM_TEST \ -DfailIfNoTests=false \ -Dwebdriver.chrome.driver=$WEBDRIVER_DIR/chromedriver_win32/chromedriver.exe \ -DargLine=-javaagent:$AGENT_DIR/selenic_agent.jar=captureDOM=true,screenshot=failures,selfHealing=true,createAPITests=false java -jar $AGENT_DIR/selenic_analyzer.jar -report $REPORT/report.html -publish /Then Execute SOAtest cd "$SOATEST_HOME" ./soatestcli.exe -data "$SOATEST_WORKSPACE " -config "user://Example Configuration" -resource $SOATEST_TEST -report $REPORT
Comments
-
Hello Chris,
I have tried the above command but unfortunately, I am getting error like "Could not find the selected project in the reactor".
Could you please let me know. If I am doing anything wrong.0 -
Hi pprakash
it looks like location of Selenium's project is not correct.
You have to two possible reasons of such behavior:- Maven execution
- incorrect location of project
First you have to check if variables SELENIUM_WORKSPACE, SELENIUM_PROJECT, SELENIUM_TEST are correct and pointing to correct location in case of execution with maven. Check if location is relative or absolute. Maybe it is relative and during maven execution is wrong.
Second check if you have whole project prepared by maven.
If still can not find reason of such behavior, try to run maven with -X switch and attach whole output here.--
Ireneusz Szmigiel
http://www.catb.org/esr/faqs/smart-questions.html0 -
"Could not find the selected project in the reactor"
This means your -pl (project list) argument has the wrong value, referencing something that doesn't exist. In this case, you ran maven from the wrong folder (SELENIUM_WORKSPACE) or specified a non-existent child module (SELENIUM_PROJECT). If you just have one module (one pom.xml file) then you don't need a "-pl" argument. You also don't need a "-Dtest" argument if you just want to run all test classes.
0 -
Dear All,
As you all suggested, I have used the command as below by excluding -pl [project list] and -Dtest arguments because I've only one pom.xml But, now the build is getting success but it is not running the test cases in ChromeDriver.
Please find my command:
mvn surefire:test -DfailIfNoTests=false -Dwebdriver.chrome.driver="H:/Drivers/Chrome/ChromeDriver 80/chromedriver.exe" -DargLine=-javaagent:G:/Parasoft_Selenic/eclipse_Selenic_2019.2/eclipse/selenic/selenic_agent.jar=captureDOM=true,screenshot=failures,selfHealing=true,createAPITests=false
Please find attached pom.rar for your reference and also I am attaching my project structure screenshot. Please suggest me if I am doing anything incorrectly.
0 -
Typically maven expects test files to be in src/test/java, but yours are simply in src. You can use a different structure, but you have to specify it in the pom - see http://maven.apache.org/ref/3.3.3//maven-model/maven.html#class_build.
0 -
@pprakash, I'm not sure how your project would build, let alone run. Your pom.xml does not specify any dependencies, no selenium-java dependency and no junit/testng dependencies. Please also set the build/sourceDirectory or build/testSourceDirectory elements if you choose not to follow the maven standard project layout.
Before trying to use the Selenic Agent ("-DargLine=-javaagent" argument), please make sure the project works with maven. For example, make sure something simple like "mvn clean test" works before trying anything else.
0 -
Thank you all for your valuable suggestions and information. Finally, I've done the project structure as you mentioned like "src/test/java" and added the required dependencies. Now, I am able to execute successfully through the command line.
0