top of page
Untitled
  • TestNG test suite developed for the automation of legalzoom.com

TestNG Test Suite Using Selenium Webdriver.: Service
TestNG Test Suite Using Selenium Webdriver.: Video

import org.openqa.selenium.By;

import org.openqa.selenium.JavascriptExecutor;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.support.ui.Select;

import org.testng.Assert;

import org.testng.annotations.AfterClass;

import org.testng.annotations.AfterSuite;

import org.testng.annotations.BeforeClass;

import org.testng.annotations.BeforeSuite;

import org.testng.annotations.BeforeTest;

import org.testng.annotations.Test;


public class BeltExam2 {


WebDriver driver;


@BeforeSuite


    public void setUp(){


System.setProperty("webdriver.chrome.driver", "/Users/ruwaydaalshowiman/Downloads/chromedriver");


        driver=new ChromeDriver();

        

        System.out.println("Set Up Chrome browser");


        

    }


@BeforeClass


    public void appSetup() throws InterruptedException{


        driver.get("https://www.legalzoom.com/");

        

        System.out.println("Opening Chrome browser");

        

Thread.sleep(3000);

    }


@BeforeTest


public void beforeTesting(){

       

    driver.manage().window().maximize();

    

    System.out.println("maximizing the window");

    

}



@Test


public void exam() throws InterruptedException {


//Scroll To found  Living Trust button


System.out.println("Scrolling down to find Living Trust button");


        

JavascriptExecutor js = (JavascriptExecutor) driver;


WebElement scrolling = driver.findElement(By.xpath("//*[@id=\"legal-help-family-media\"]/div/div/div[2]/div/p[3]/a[2]"));


js.executeScript("arguments[0].scrollIntoView();",scrolling);


Thread.sleep(3000);



System.out.println("The Scroll To the Living Trust is Done");


scrolling.click();


Thread.sleep(3000);



WebElement startlivingbtn = driver.findElement(By.id("hero915-cta-button"));


startlivingbtn.click();


System.out.println("Clicking on Basic Living Trust button");



WebElement getStartedElement = driver.findElement(By.xpath("//*[@id=\"collapse1623156477351-1\"]/div/div/a"));


getStartedElement.click();


Thread.sleep(2000);



// applying personal information


System.out.println("Applying The personal information");


WebElement emailbtn = driver.findElement(By.cssSelector("input[id='ctl00_cphMainContent_btnContinue2']"));//cssSelector("input#m_login_password"));


emailbtn.click();


Thread.sleep(3000);



WebElement checkbtn1 = driver.findElement(By.cssSelector("input[name^='chkctlgrantor_']"));


checkbtn1.click();


Thread.sleep(3000);



WebElement btn2 = driver.findElement(By.cssSelector("input[id$='_btnContinue2']"));


btn2.click();


Thread.sleep(3000);



WebElement fname = driver.findElement(By.id("grantor_first"));


fname.sendKeys("Najeba");


Thread.sleep(1000);



WebElement mname = driver.findElement(By.xpath("//input[@id='grantor_middle']"));


mname.sendKeys("Hashim");


Thread.sleep(1000);



WebElement lname = driver.findElement(By.xpath("//input[contains(@id,'_last')]"));


lname.sendKeys("Alhashim");


Thread.sleep(1000);



WebElement nkname = driver.findElement(By.xpath("//input[contains(@name,'grantor_aka')]"));


nkname.sendKeys("Njoob");


Thread.sleep(2000);



Select married = new Select(driver.findElement(By.xpath("//select[@id=\"grantor_married_MC\"]")));


married.selectByIndex(1);


Thread.sleep(2000);



Select child = new Select(driver.findElement(By.id("grantor_children_MC")));


child.selectByValue("No|~|428854");


Thread.sleep(3000);



WebElement btn3 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn3.click();



WebElement fname2 = driver.findElement(By.id("grantor_spouse_first"));


fname2.sendKeys("Najeba");


Thread.sleep(1000);



WebElement mname2 = driver.findElement(By.xpath("//input[@id=\"grantor_spouse_middle\"]"));


mname2.sendKeys("Hashim");


Thread.sleep(1000);



WebElement lname2 = driver.findElement(By.xpath("//input[@id=\"grantor_spouse_last\"]"));


lname2.sendKeys("Alhashim");


WebElement btn4 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn4.click();


Thread.sleep(1000);



WebElement address = driver.findElement(By.xpath("//input[@id=\"grantor_address\"]"));


address.sendKeys("Alahsa");


Thread.sleep(1000);



WebElement city = driver.findElement(By.xpath("//input[@id=\"grantor_city\"]"));


city.sendKeys("Alahsa");


Thread.sleep(1000);



WebElement residence = driver.findElement(By.xpath("//input[@id=\"grantor_county\"]"));


residence.sendKeys("Al Hofuf");


Thread.sleep(1000);



Select state = new Select(driver.findElement(By.xpath("//select[@id=\"grantor_state\"]")));


state.selectByIndex(10);


Thread.sleep(2000);



WebElement zipCode = driver.findElement(By.xpath("//input[@id=\"grantor_zip\"]"));


zipCode.sendKeys("1234");


Thread.sleep(2000);



WebElement btn5 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn5.click();


Thread.sleep(2000);



// applying Property information


System.out.println("applying Property information");



WebElement btn6 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn6.click();


Thread.sleep(2000);



WebElement checkbox1 = driver.findElement(By.xpath("//input[@id=\"chkctlproperty_realestate_CB\"]"));


checkbox1.click();


Thread.sleep(1000);



WebElement checkbox2 = driver.findElement(By.xpath("//input[@id=\"chkctlproperty_personal_CB\"]"));


checkbox2.click();


Thread.sleep(1000);



WebElement btn7 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn7.click();


Thread.sleep(1000);



WebElement address2 = driver.findElement(By.xpath("//input[@id=\"property_realestate_info_address_1\"]"));


address2.sendKeys("Alahsa");


Thread.sleep(1000);



WebElement city2 = driver.findElement(By.xpath("//input[@id=\"property_realestate_info_city_1\"]"));


city2.sendKeys("Alahsa");


Thread.sleep(1000);



Select state2 = new Select(driver.findElement(By.xpath("//select[@id=\"property_realestate_info_state_1\"]")));


state2.selectByIndex(10);


Thread.sleep(2000);



WebElement zipCode2 = driver.findElement(By.xpath("//input[@id=\"property_realestate_info_zip_1\"]"));


zipCode2.sendKeys("1234");


Thread.sleep(2000);



Select realState = new Select(driver.findElement(By.xpath("//select[@id=\"property_realestate_info_type_1\"]")));


realState.selectByVisibleText("Home");


Thread.sleep(2000);



Select transferdeed = new Select(driver.findElement(By.xpath("//select[@id=\"property_realestate_info_deed_1\"]")));


transferdeed.selectByIndex(1);


Thread.sleep(2000);



WebElement btn8 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn8.click();



WebElement checkbox3 = driver.findElement(By.xpath("//input[@id=\"chkctldeed_tos_CB\"]"));


checkbox3.click();



WebElement btn9 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn9.click();


Thread.sleep(2000);



Select assets = new Select(driver.findElement(By.xpath("//select[@id=\"property_personal_MC\"]")));


assets.selectByIndex(0);



WebElement btn10 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn10.click();


Thread.sleep(2000);



WebElement btn11 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn11.click();



// applying Gift information


System.out.println("applying Gift information");



WebElement btn12 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn12.click();


WebElement btn13 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn13.click();



WebElement giftpercentage = driver.findElement(By.xpath("//input[@id=\"grantor_heir_info_percent_1\"]"));


giftpercentage.sendKeys("100%");


Thread.sleep(1000);



WebElement to = driver.findElement(By.xpath("//input[@id=\"grantor_heir_info_name_1\"]"));


to.sendKeys("Hanan abdulhadi");


Thread.sleep(1000);



WebElement btn14 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn14.click();



WebElement btn15 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn15.click();



WebElement btn16 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn16.click();



Select no = new Select(driver.findElement(By.xpath("//select[@id=\"pow_MC\"]")));


no.selectByIndex(1);


Thread.sleep(2000);



WebElement btn17 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn17.click();


Thread.sleep(2000);



// applying Representative information


System.out.println("applying Representative information");


WebElement btn18 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn18.click();



WebElement btn19 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn19.click();



WebElement fullname = driver.findElement(By.xpath("//input[@id=\"first_successor_trustee\"]"));


fullname.sendKeys("jafar mohammed alhashim");


Thread.sleep(2000);



WebElement btn20 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn20.click();



// applying an additional options information


System.out.println("applying an additional options information");


WebElement btn21 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn21.click();



WebElement btn22 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn22.click();



WebElement checkbox4 = driver.findElement(By.xpath("//input[@id=\"chkctllw_self_CB\"]"));


checkbox4.click();



WebElement btn23 = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_btnContinue2\"]"));


btn23.click();



// continue to checkout choosing basic living trust


WebElement continuebtn = driver.findElement(By.xpath("/html/body/form/div[3]/table/tbody/tr[3]/td/div[4]/input"));


continuebtn.click();


Thread.sleep(3000);



WebElement radio = driver.findElement(By.xpath("//input[@name='fkPostOption' and @value='6695']"));


radio.click();


Thread.sleep(2000);



WebElement continuebtn2 = driver.findElement(By.xpath("//input[@id=\"ctl00_ContentPlaceHolder1_imgButton_Continue\"]"));


continuebtn2.click();


Thread.sleep(2000);



WebElement checkout = driver.findElement(By.xpath("//*[@id=\"button-next\"]/img"));


checkout.click();


Thread.sleep(2000);



//completing the order information


System.out.println("completing the order information");



WebElement firstname = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_txt_ContactInfo_FName\"]"));


firstname.sendKeys("Najeba");


Thread.sleep(1000);



WebElement lastname = driver.findElement(By.xpath("//input[contains(@id,'txt_ContactInfo_LName')]"));


lastname.sendKeys("Alhashim");


Thread.sleep(1000);



WebElement emailadd = driver.findElement(By.xpath("//input[@type='text' and @id=\"ctl00_cphMainContent_txt_ContactInfo_EmailAddress\"]"));


emailadd.sendKeys("najebaalhashim@gmail.com");


Thread.sleep(1000);



WebElement phone = driver.findElement(By.cssSelector("input[id='ctl00_cphMainContent_txt_ContactInfo_PhoneNumber']"));


phone.click();


phone.sendKeys("(055)888-5412");


Thread.sleep(3000);



WebElement add = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_txt_ContactInfo_Street1\"]"));


add.sendKeys("Alahsa");


Thread.sleep(1000);



WebElement zip = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_txt_ContactInfo_ZipCode\"]"));


zip.sendKeys("31982");


Thread.sleep(1000);



WebElement cityname = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_txt_ContactInfo_City\"]"));


cityname.sendKeys("Alahsa");


Thread.sleep(1000);



Select states = new Select(driver.findElement(By.xpath("//select[@id=\"ctl00_cphMainContent_ddl_ContactInfo_State\"]")));


states.selectByIndex(5);


Thread.sleep(2000);



// payment information


System.out.println("Applying payment information");



WebElement first = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_txt_PaymentInfo_FName\"]"));


first.sendKeys("Najeba");


Thread.sleep(1000);



WebElement last = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_txt_PaymentInfo_LName\"]"));


last.sendKeys("Alhashim");


Thread.sleep(1000);



WebElement card = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_txt_CC_Number\"]"));


card.sendKeys("19863542981");


Thread.sleep(1000);


        

Select month = new Select(driver.findElement(By.xpath("//select[@id=\"ctl00_cphMainContent_ddl_CC_ExpirationMonth\"]")));


month.selectByIndex(3);


Thread.sleep(2000);



Select year = new Select(driver.findElement(By.xpath("//select[@id=\"ctl00_cphMainContent_ddl_CC_ExpirationYear\"]")));


year.selectByIndex(6);


Thread.sleep(2000);



WebElement billingzip = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_txt_CC_ZipCode\"]"));


billingzip.sendKeys("31982");


Thread.sleep(1000);



WebElement cvv = driver.findElement(By.xpath("//input[@id=\"ctl00_cphMainContent_txt_CC_SecurityCode\"]"));


cvv.sendKeys("374");


Thread.sleep(3000);



WebElement finalbtn = driver.findElement(By.xpath("//a[@id=\"ctl00_cphMainContent_imgbtn_CheckOut\"]"));


finalbtn.click();


Thread.sleep(3000);



//Assert an alert


String alertMessage= driver.findElement(By.xpath("//span[@id='ctl00_cphMainContent_cv_txt_CC_Number']")).getText();

        

        String expectedMessage = "Invalid Credit Card Number";

        

        Assert.assertEquals(expectedMessage,alertMessage);

        

        System.out.println(alertMessage);

        

        Thread.sleep(3000);

        

    }


@AfterClass


public void afterTesting(){


driver.quit();

}


@AfterSuite


public void cleanUp(){

       

        System.out.println("The Test is Done");

    }


}

TestNG Test Suite Using Selenium Webdriver.: Text

©2021 by Ruwayda Alshowiman.

bottom of page