New to Selenium and working on few hands on activity. Below is my query:
An application has been developed which enrolls the user details to the shipment company. Using the application user can track their shipment status and details.
URL:
http://webapps.tekstac.com/Handling_Regular_Expression/[
^]
Below is the Test Procedure:
1.Use the template code.
2.Don't make any changes in DriverSetup file.
3.Only in the suggested section add the code to,
4.Invoke the driver using getWebDriver() method defined in DriverSetup()
Implement the following methods:
public void setFormValues(WebDriver driver)
5.Identify the shipment for user text box and set the value as “Shamili”
6.Identify the Search button and click on the same
public WebElement getNameResultElement(WebDriver driver)
7.In the result page, find the element of 'Shamili' and return it. public WebElement getShipmentResultElement(WebDriver driver)
8.In the result page, find the element of 'SHIP1236' and return it. public WebElement getEmailResultElement(WebDriver driver)
9.In the result page, find the element of 'shamili93@gamil.com' and return it.
10.Get the e-mail from div id "e- mail" and shipment id from div id "shipment".
11.Validate the values of e-mail and shipmentId using the below methods.
public boolean validateEmail(String eMailID) { public boolean validateShipmentId(String shipmentId)
Validation pattern is given below,
mail:\\b[A-Z0-9a-z-]+@[a-z]+\\.[a-z]{2,4}\\b
ShipmentID:[A-Z0-9]{8}
12.Return 'true' or 'false' boolean value based on the findings.
What I have tried:
This is the code that I have done so far. Saw few regEx examples online but none seems to work when I compile it and I am stuck.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
public class NameLocator {
public static String baseUrl;
public static WebDriver driver;
public WebDriver createDriver()
{
DriverSetup ds = new DriverSetup();
driver = ds.getWebDriver();
baseUrl = "http://webapps.tekstac.com/Handling_Regular_Expression/";
return driver;
}
public void navigate(WebDriver driver){
driver.navigate().to(baseUrl);
}
public void setFormValues(WebDriver driver)
{
WebElement userId = driver.findElement(By.id("userId"));
userId.sendKeys("Shamili");
WebElement track = driver.findElement(By.id("track"));
track.click();
}
public WebElement getNameResultElement(WebDriver driver) {
return driver.findElement(By.xpath("/html/body/div/table/tbody/tr[1]/td[2"));
}
public WebElement getShipmentResultElement(WebDriver driver) {
return driver.findElement(By.id("shipment"));
}
public WebElement getEmailResultElement(WebDriver driver) {
return driver.findElement(By.id("e- mail"));
}
public boolean validateEmail(String eMailID) {
String Emailregex = "^[A-Za-z]\\w{5,29}$";
}
public boolean validateShipmentId(String shipmentId) {
String Shipmentregex = "[A-Z0-9]{8}";
}
public static void main(String[] args)
{
NameLocator reg=new NameLocator();
}
}