I have installed the Jenkins on my windows machine.
I am currently doing the functional testing of a website and i have created all the test cases using selenium . I ran all these testcases using eclipse with testng plugin.
Now is there any way where i can run these testcases in eclipse from Jenkins itself i.e Can i control the eclipse from Jenkins.
I am trying hard now and able to run it using batch command( i have written all the commands in a batch file to run the eclipse and selenium driver and that batch file is executed from Jenkins ) but i am in search of a plugin where i can run directly the eclipse , selenium web-driver using that plugin.
Please see to this issue.
Thanks.
You are on the right lines with a batch file, but I recommend you use Ant or Maven instead of Eclipse - they are the standard way of scripting builds in Java, and they have good Jenkins support.
Here is a plugin for Maven to start up Selenium before the tests: http://mojo.codehaus.org/selenium-maven-plugin/
Here is how to run your TestNG tests using Maven: http://maven.apache.org/plugins/maven-surefire-plugin/examples/testng.html
Related
I'm trying to use jenkins to create automated regression tests for a web app. Jenkins basically fetches my maven project from git and reads the pom.xml. Then the test suite is started. The problem is that my tests are using selenium web driver in combination with gekodriver in order to launch firefox and navigate on the website. But everytime I launch the tests I get those errors:
Console logs
I'm running Jenkins as a service (it's how it was launched after installation) and my tests work fine when ran through eclipse or java. So I think the problem comes from how the jenkins handles selenium webdriver.
As you can probably see, I'm on a Windows 7 professional license. Firefox and gekowebdriver are updated to the last versions.
Fixed:
Jenkins being ran as a service was the problem. In order for selenium to properly display firefox, it needed to access the desktop. Fixed the issue by simply allowing Jenkins service to use the desktop. It makes for a poor fix but it works fine.
I have application(Spring boot, Gradle).
Now I need to find a possible and easier way to convert HTML scenario (created with Selenium IDE) to JUnit tests automatically (maybe run some Gradle task).
I found some plugins like - https://github.com/willwarren/selenium-maven-plugin (based on Maven) and https://github.com/nextinterfaces/selenium4j (based on Ant).
How can I add this plugin to my application? Is it posible to add maven or ant based plugin to gradle based application?
Maybe some plugins for gradle also exist?
Any help will be highly appreciated.
In the selenium IDE, you will find the option in File menu to export your test case in multiple languages.
Goto: File> Export Test Case As> Java / JUnit 4 / Web Driver
Here's a screenshot showing this:
Export test case in Selenium to Java JUnit
friends. I try to understand how does selenium work. I written some tests with JUnit 4. These tests works fine when my app is running and I put as URL localhost:8077 where my app is started. All tests pass as I need. But now I want that my war build will depend by these tests. After these I want that the automated release (Jenkins) will also depend by selenium tests.
I don't understand some things:
Should the selenium test be included in my application or they should be assembled in a standalone application? (I read about Selenium Grid but I am not sure that I need it)?
I have one developer machine, one server with jenkins and the production server. What are the needed steps to implement Selenium test? What Url should be used in test? Is it needed to install Tomcat Server on the same server with Jenkins?
Can I invalidate the build and drop the release on Jenkins if selenium tests are not passed?
Should the selenium test be included in my application or they should be assembled in a standalone application? (I read about Selenium Grid but I am not sure that I need it)?
It depends on how you want to run your tests. Best practice is to call the test configuration inside your maven project and tests will run during your build job. You can also call your maven target after the build is completed.
Selenium Grid is useful but only if you have dedicated machines having proper setup to run those tests, else your tests may often fail. You should consider running your tests remotely on cloud using services like Saucelabs, etc.
I have one developer machine, one server with jenkins and the production server. What are the needed steps to implement Selenium test? What Url should be used in test? Is it needed to install Tomcat Server on the same server with Jenkins?
Selenium tests can be implemented with Maven on Jenkins following the step from here, here and here.
Dev or Test URLs should be used for running the test.
I think you would need Tomcat Server if you are hosting your application on the Jenkins machine or else it should not be needed.
Can I invalidate the build and drop the release on Jenkins if selenium tests are not passed?
When you include the test configuration in your project configurations, the build may fail during the build job if your test fails. You can set how you want to proceed with your build when you test fails like failing the build or pass the build with warning. You may want to get notifications for failed build also.
Ex. Jenkins marks good build as failure because of test failed
Jenkins plugins can be used based on the needs.
You may like to read more about How to do Integration tests here.
I'll do my best to answer your questions, and hopefully clear a few things up for you.
From my experience each test should be created as a new item and then configured to run after your app is deployed or periodically. No you dont need Selenium Grid. It is used for parallel execution of tests.
You'll need to configure your machines as nodes on jenkins and install the jenkins agent on the slave machines. Setting up selenium tests differs depending on how you have written the tests, for example i use maven as my build tool. So for each new test i only need to point towards svn and give the maven launch commands. The url is whatever url you use to access your app. There is a very good article on how to setup jenkins on their site, you can find it here
Yes.
I'm very new for Appium. I have configured all my Win-7(64 bit) machine using this blog i.e Appium for windows, node.js and Android SDK with API level 17, emulator etc.
I found many java files on git-hub also in this blog also
but How to run this java files I don't have idea.
If anybody guide me step wise will be very helpful.
Thanks.
You can run the java test file using following command:
mvn -Dtest=com.saucelabs.appium.SimpleTest test
Note: You need to open terminal -> navigate to project directory --> execute the above command.
Refer to this link: Run Java Test File
For command line execution you can integrate your automation test with build tools.
Like Ant, Maven, Gradle. it can help you to execute and build automation test, also you can easily integrate with CI tools with the help of these.
apologies for the somewhat confusing title :-) Basically, I've configured my Selenium tests to run through JUnit when I build the project through maven. If I start my Selenium Server in a command prompt and then run the maven build goal in another cmd prompt then the tests runs as expected.
I figured that this process would be easy to implement in Hudson but it has proven quite problematic. I can start my selenium server as before and then configure the build to kick off via a hudson job. However, hudson doesn't seem to be picking up the selenium server - I get an error message which says the following:
Unable to obtain goal [test:test]
The reason I think that hudson isn't contacting the selenium server is because when I run the junit tests through my own command prompt with my server stopped, I get the same error message.
Its also important to note that I used to use the seleniumHQ plugin for hudson to run my tests using html files - but wish to change to JUnit as its more flexible.
Any help on this is very much appreciated!
Thanks,
Gearoid.
I recommend that you run selenium tests separately from the test:test goal.
You can create two hudson builds for your project, with the second build being triggered by the successful completion of the first build.
Why would you do this?
Unit tests complete faster, so your feedback time is mush shorter
the second build can run a shell script or ant instead of maven, allowing you easier control of your remote server
The selenium tests won't be triggered by mvn test on a developer machine, which could cause conflicts.
You can run two hudson nodes in a "farm" configuration, the second instance can run on the same server as selenium. Server affinity can be set up for specific builds.
Is there a config file with the server URL that is not being picked up running inside Hudson? Can you print the server URL to make sure it's pointing at the right place?
You could use the selenium-maven-plugin to start and stop the selenium server automatically as part of the maven build process.