Project Status: 90%
Just a simple to use, extremely portable, cross-platform, command line operable, java-based, Selenium + testNG framework for web automation testing on the usual suspects of browsers. Tutorial videos to come eventually…
TestExample.java
) and write Selenium tests as desired using TestNG for assertions
driver.get("<URL>");
// navigates to desired url
driver.findElement(By.className("button")).click();
// clicks on the warning button
driver.findElement(By.id("username")).sendKeys("example-user");
// finds login text box and types "example-user"
WebElement myInput = driver.findElement(By.cssSelector("input"));
// finds an element based on its CSS selector and copies a reference to a local variable for future interaction with this element
Assert.assertEquals(driver.getTitle(), "Google");
// asserts the web site title is "Google"
Assert.assertEquals(myInput.getAttribute("value"), "4200");
// asserts the myInput value is "4200"
WAFScreenShotter
utility class
```java
package util;new WAFScreenShotter(
- do not add a file extension to the picture name argument, a `.jpg` is automatically added
- if you already have a `WAFScreenShotter` object you can simply use the `.takeScreenshot()` method to take another screenshot
```java
myWAFScreenShotter.takeScreenshot(driver, "example");
// takes picture and places "example.jpg" in current directory
WAFFileDownloader
utility class
```java
package util;new WAFFileDownloader(
- be sure to include "Files" (capitalization matters) somewhere in your folder name if you want the folder deleted when `make clean` is run
- almost all of your CSS selectors should end in `a` since you should be clicking links to download files
- if you already have a `WAFFileDownloader` object you can simply use the `.downloadFiles()` method to download additional files
```java
myWAFFileDownloader.downloadFiles(driver, "my-Files-Folder", "td > a");
// downloads all files on the page that are table element links
make
make compile
java -cp .:res/* Main <OPTIONAL ARGUMENTS>
javac -cp "res/*;." util/*.java
javac -cp "res/*;." *.java
java -cp "res/*;." Main <OPTIONAL ARGUMENTS>
<OPTIONAL ARGUMENTS>
is replaced by your command line arguments
-b
or --browser
followed by browser name (chrome
, firefox
, edge
, ie
) for specific browser
chrome
-w
or --width
followed by port number for specific browser width
1024
-h
or --height
followed by port number for specific browser height
768
-p
or --port
followed by port number to run on a specific port number
0
(web driver will automatically choose ports)-u
or --url
followed by ip address for specific ip/site to be used
-t
or --tag
followed by a non-spaced comma-separated value of test class names
Example1, Example2
to run TestExample1 and TestExample2 test classes for exampleExample
test-output
will be generated
html
exists and within that is the index.html
file containing the reportNG report of how the tests wenttestng-results.xml
is an xml
report that can be used to display results within an environment like Jenkins or Zephyrmake clean
make superclean
build.xml
(recreated by Main.java
each run) and the pdf copy of this READMEThis framework works in the following manner:
1) All java files are compiled
2) Main is run
1) Parses optional arguments
2) Creates build.xml
TestNG
3) Uses build.xml
as a template to run tests
1) Initializes web driver
2) Performs actions using Selenium
3) TestNG test assertions are checked
3) TestNG framework creates output .html
and .xml
files to view test results
make
runs the following commands:
javac -cp .:res/* util/*.java
javac -cp .:res/* *.java
java -cp .:res/* Main
make compile
runs the following commands:
javac -cp .:res/* util/*.java
javac -cp .:res/* *.java
make clean
runs the following command:
rm -rf test-output *Files* *.class util/*.class *.zip *.png *.jpg
make superclean
runs the following command:
rm -rf test-output *Files* *.class util/*.class *.zip *.png *.jpg *.pdf docs/*.pdf *.xml
5.1-7.1
would run every test that exists in that range5.1.1
would run just that specific step (wrapped in login and quit)smoke
would run just tests labeled with smokenot debug
would run all tests that aren’t debugkillall chromedriver
or killall geckodriver
drivers
folder