How to transport a Selenium package to a client environment? - selenium

I need to develop a automation package using selenium and send it over to a different location and completely different environment so that it will aid in the testing's happening there. It has to be able to be integrated with Jenkins for the build run. Also it should be a data driven package.
how will I be able to do that?

You need to create repository and upload the tests there and provide access to the client. You can use service like Github or Gitlab. You can have private repository for up to 3 contributors.
You can parametrize the test using property file or system property variables.
If you need more information about how the system properties work you can check this article: https://www.baeldung.com/java-system-get-property-vs-system-getenv
Something like this:
System.getProperty("log_dir", "/tmp/log");
mvn clean test -DpropertyName=value
If you want to send the project like a jar file then it will be like:
System.getProperty("baseUrl", "https://mywebsite.com");
java -jar jarName -DbaseUrl=https://someotheraddress.com

Related

Exploring options to deliver Selenium test to non-tech business team who wish to run the test on their own

Our non-technical business team need to run only 1 automation test script which will be fetching data from several hundreds rows of Excel file. I've created automation that script using a Maven project (with POM framework and Extent Report), using Selenium WebDriver, Java, TestNG, and Eclipse but not sure how to deliver the test/script to the business team. Would appreciate if you guys can suggest a few options to deliver this script to the business team so that they can change few parameters in Excel file and run the script on their own. I'm getting Extent report at the end of the test, would be best if they can get the Extent report as well.
Note: Since they are non-technical, it is preferable to avoid installing and configuring Java, Eclipse, etc tools on their machine but that's not mandatory so I'm open to check several options.
I would like to suggest few options here :
Jenkins - Install it on Any server and share login and url with them. They can execute build and no technical knowledge required.
Executable JAR - Export your project as executable JAR and deliver that JAR file. All they have to do it , Double click on JAR file OR execute via batch file and it should run that script and get done the job. Make sure all data related file should be there with JAR. i.e excel file
Note : They always need JAVA in the machine regardless of what they prefer from above to use.
Usually i used to give as batch file script, if you have jenkins, integrate your bat file in it. other wise share the batch file as it is.
Create a package JAR,
Create .bat file to execute the JAR.

Best practice to create .NET Web API using generated Server Stub

b) After generating the .NET C# server stub, the documentation is not very verbose about how to use it:
You need to implement the logic yourself to handle whatever work the
API needs to do. Once the implementation is ready, you can deploy the
API locally or on your server. See the README.md file in the
downloaded archive to get started.
Is there any tutorial about how to use the code? I would like to use inheritance to avoid code changes of the generated code. But the documentation talks about just ignoring some generated files. The swagger support told me to just "migrate" the changes on every change. What is possible, but I hoped to be able to leave generated files untouched. Am I wrong here, is there no parctical need for this? I would like to use the server stub in a continuous integration environment.
One option you have is to customize the templates.
Clone the swagger-codegen repository.
Assuming you are using the latest stable v2 version of the code generation tool, then master branch is fine. Otherwise checkout the tag for the tool version you are using.
In Windows Explorer, open swagger-codegen\modules\swagger-codegen\src\main\resources\ and copy the aspnetcore directory. Paste that into your customer source code repository.
When next you run the codegen tool, provide the -t argument:
java -jar swagger-codegen-cli.jar generate
-i <your Open API spec URL/file>
-l aspnetcore
-o <outputdir>
-t <relative path to your>\aspnetcore
... other args as needed
Now you can modify those templates with custom code. For example, you could have an external library with a new base controller class that provides some generic business logic. Then you could modify the controller.mustache file to reference your base class. Just one of many examples. Add your custom templates to your source control for continuous integration.
Caveats: There is a controller.mustache file directly in aspnetcore and another in aspnetcore\2.1. In studying the source code, I see that the 2.1 folder is used for any version of ASP.NET Core other than 2.0. I'm new to this tool myself and have not fully figured out how to exploit it; the utility generates source code that will not build for me out of the box. It does not generate the security classes, but it does generate code that tries to use those security classes. Thus I'm having to comment out the security code in the templates.

selenium-server-standalone.jar maven dependency

I am using Maven as a build tool. On selniumhq site I can see selenium-server-standalone.jar file but I could not found related Maven dependency. Is there any maven dependency for selenium standalone file?
latest selenium standalone file is : selenium-server-standalone-3.2.0.jar
Note : I want to execute code on Remote desktop machine using Selenium grid (which require aforementioned jar file)
I think you should refer to this manual first: http://www.seleniumhq.org/docs/07_selenium_grid.jsp#starting-selenium-grid
i.e. in order to use grid you need you need to create grid instance first by running commands
from command line, then you need to register node, again by using command line, and after that from your code you need to create instance of RemoteWebDriver (refer to this page for more details: http://www.seleniumhq.org/docs/04_webdriver_advanced.jsp#remotewebdriver).
If, for some reason, you want to to create grid\register nodes from your project maybe it makes sense to download it to your resources folder, execute it from there using Runtime (refer to this link for more details: http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html) and then connect to it. But I would strongly recommend avoiding doing so.

Upload non java artifacts to nexus 3.1.0-04

I want to be able to upload a non java artifact to hosted nexus3 repository. For this I used the curl commands described in this link uploadToNexus, but it worked only for nexus 2. I noticed also that we can create groovy script, upload them to nexus and run them (RestApi, but I'm not sure if we can create a groovy script to upload artifacts. Is there a groovy script giving this possiblity ? I'm wondering also if there is any non maven alternative to the maven deploy plugin ?
Thanks in advance.
If it's a non Java artifact, you might look at using our RAW repository, depending on what it is. However, if you for sure want to use a Maven repository, the good news is you can :)
Assuming you have a fairly normal local setup, go with something akin to this. The big change between Repository Manager 2 and 3 is that the endpoints changed, which is why the old commands are not working for you.
curl -v -u admin:admin123 --upload-file file.jar http://localhost:8081/repository/releases/org/foo/1.0/file.jar

How to run same specflow tests against various environments?

I'd like to write one suite of SpecFlow tests that test my web application (using Selenium) in various environments.
so I have a test written like this
Given that I am on the login page
which in turn leads to a step definition that boils down to
driver.Navigate().GoToUrl("http://www.myapp.com/login.aspx");
However, I want my test to be able to run against "http://localhost" or `"http://test.myapp.com" as well, without having to recompile. The best idea I've come up with is to place these sorts of settings in the App.config file, but that has its problems as well.
Does anyone have suggestions on how best to achieve this? Basically I want to pass in environment settings for my tests at runtime.
You can do this by changing the config file through the build process using transforms and there are tools that will let you run the transform outwith the build process (so you don't have to manually change it and you avoid a build) using the command line. This has been talked about already on SO:
Web.Config transforms outside of Microsoft MSBuild?
For example using PowerShell.
I would still question whether you might be better and starting a local instance of the service that you wish to test, rather than connecting to something which is out of the tests explicit control. You could instead use a method similar to self hosting a web api or host a wcf service to do this for you. This way you can inject mocks, modify and reset the database, or perform any other action you want.
If that still isn't what you need, an alternative to config files would be to setup environment variables that can be read at run time, see How to pass Command line argument to specflow test scenario