Require: Java 8 (or higher), JUnit, and Selenium.
Additional resources: You may find class discussions on test automation, and characteristics of good tests helpful when designing and automating your tests.
You may work alone or with another student in this course.
Consider Compute Project Grade app. Use the following examples to help you find and extract information from the app and imitate users' interactions.
Develop at least 5 test methods (that are different from the tests we created together in class) — be sure to use proper test oracles. Each test must target different purposes or verify different facts.
You may create a Selenium test file from scratch or use the provided computePrjGradeTest_template.java.
The following examples assume that a driver is an instance of a WebDriver
and an element is an instance of a WebElement.
private WebDriver driver; private WebElement element;
driver.findElement(By.tagName("name-of-the-html-tag"))
Note: findElement() returns the first matched element.
To find all elements that match, use findElements().
driver.findElements("name-of-the-html-tag"))
Note: findElements() returns a list of all WebElements that match the condition,
and thus we can iterate over the list to extract information about the elements.
For example:
List<WebElement> lstElem = driver.findElements(By.tagName("input"));
for (int i=0; i<lstElem.size(); i++)
{
System.out.println(i + " : " + lstElem.get(i).getAttribute("name") + " : " +
lstElem.get(i).getAttribute("type") + " : " + lstElem.get(i).getAttribute("value"));
}
driver.findElement(By.name("name-of-the-element"))
Note: Each HTML element comes with a set of attributes.
Some attributes are applicable to certain kinds of HTML elements.
driver.findElement(By.id("id-of-the-element"))
// find an HTML element of type text (i.e., a textbox)
driver.findElement(By.xpath("(//input[@type='text'])"))
// find the 2nd textbox of the page
driver.findElement(By.xpath("(//input[@type='text'])[2]"))
// an alternative way
driver.findElement(By.xpath("(//input[@type='text'])[position()=2]"));
// find the last textbox of the page
driver.findElement(By.xpath("(//input[@type='text'])[last()]"))
// find the one before last textbox of the page
driver.findElement(By.xpath("(//input[@type='text'])[last()-1]"))
// find an input element whose name starts with 'some-string'
driver.findElement(By.xpath("(//input[starts-with(@name, 'some-string')])"));
// find an input element whose id starts with 'some-string'
driver.findElement(By.xpath("(//input[starts-with(@id, 'some-string')])"));
// find an input element whose id = 'something'
driver.findElement(By.xpath("(//input[@id='something'])"));
// find an element (without specifying the kind element) whose name = 'something'
driver.findElement(By.xpath("(//*[@name='something'])"));
// find an element (without specifying the kind element) whose id = 'something'
driver.findElement(By.xpath("(//*[@id='something'])"));
// find an input element whose name attribute contains 'some-string'
driver.findElement(By.xpath("//input[contains(@name, 'some-string')]"));
// find an input element whose name attribute ='something1' and value attribute ='something2'
driver.findElement(By.xpath("//input[@name='something1' and @value='something2']"));
// find an input element whose name attribute ='something1' or value attribute ='something2'
driver.findElement(By.xpath("//input[@name='something1' or @value='something2']"));
// find all input elements of type radio (i.e, radio buttons)
driver.findElements(By.xpath("//input[@type='radio']"))
// find all elements (without specifying the kind element) of type radio (i.e, radio buttons)
driver.findElements(By.xpath("//*[@type='radio']"))
// find all input elements of type checkbox
driver.findElements(By.xpath("//input[@type='checkbox']"))
// find a button by text on the button
driver.findElement(By.xpath("//button[text()='text-on-the-button']"))
// find a button by partial text on the button
driver.findElement(By.xpath("//button[contains(text(), 'partial-text-on-the-button')]"))
// find a link by a link text
driver.findElement(By.linkText("link-text"))
// find a link by partial link text
driver.findElement(By.partialLinkText("partial-link-text"))
driver.getTitle()
driver.getPageSource() Note:getPageSource()returns a string and thus string's operations are applicable (e.g.,contains("some string"))
element.getText() Note:getText()returns a string and thus string's operations are applicable (e.g.,contains("some string"))
element.getTagName()
element.getAttribute("name-of-attribute")
Note: Some commonly used attributes are name, value, type.
element.getLocation() element.getLocation().getX() element.getLocation().getY()
element.sendKeys("input-to-be-entered")
Note: sendKeys() allows us to imitate the situation when
a user clicks in a textbox and enter an input.
Thus, we first need to find the target element before entering an input.
element.click()
Some brief info that may help you familiarize yourself with basic web app concepts / syntax: HTML overview and intro to HTML and CSS
For a complete set of elements and attributes, please refer to W3C HTML.
(-2.5 points) for 24 hours late (submitted after 20-May-2026 11:59pm EST, by 21-May-2026 11:59pm EST)
(-5 points) for 48 hours late (submitted after 21-May-2026 11:59pm EST, by 22-May-2026 11:59pm EST)
Verify that the correct file is submitted.
Making your submission available to instructor and course staff is your responsibility; if we cannot access or open your file, you will not get credit. Be sure to test access to your file before the due date.
CC-BY-NC-SA 4.0 license.