Integrating Custom Selenium Code & Scriptless

You are here:
< All Topics

Selenium Custom Scripts

    • Click on Add Custom Script
    • Below the Popup box will appear on the screen.

    • Add a Test Case Name and Description.
    • Add your scripts on Custom Script.
    • Click on Save.


Call Custom Script

    • This action is for Android, iOS, and Web.
    • This action is used to call the custom script that you created in a custom script section.

Selenium Custom Script

    • For Web we can write custom scripts in Java using the TestNG framework.
    • We can use the “driver” object to access all methods of WebDriver class.
    • Following are some examples:
Sample 1
WebElement reqdate =driver.findElement(By.xpath("//input[@id='outerForm:billingCycleRequestDate_input']"));


Sample 2
WebElement planNameEleme = driver.findElement("outerForm:grid:0:planCodeTextOut2"));

String planeNameStr = planNameEleme.getText().trim();
boolean isValidPlan = planeNameStr.contains("WHOLE") || planeNameStr.contains("UNIVERSAL");

Assert.assertTrue(isValidPlan,"Plan name does not contain Whole Life or Universal Life");
Sample 3
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("MM/dd/yyyy");
         try {
             java.util.Date date = formatter.parse(var_PaidToDate.trim());
             java.util.Calendar c = java.util.Calendar.getInstance();
             java.util.Date onePlusDate = c.getTime();
             var_OneYearPlusPaidToDate = formatter.format(onePlusDate);

          } catch (ParseException e) {
              System.out.println("Conversion from String to Date Failed. Please check PaidToDate format.");
Sample 4
WebElement premimumAmountweb = driver.findElement(By.xpath("//span[@id='outerForm:grid:0:appliedAmountOut2']"));

String premimumAmounttext  =premimumAmountweb.getText().trim();
writeToCSV("Member Identifier", var_MemberIdentifier);
writeToCSV("PAGE #: DATA TYPE", "SRP445 Applied Amount");
writeToCSV("GIAS DATA",premimumAmounttext);
writeToCSV("PDF DATA", var_AmounttoAppliedPDF);
writeToCSV("RESULT", (premimumAmounttext.equals(var_AmounttoAppliedPDF)) ? "PASS" :
java.time.LocalDate date =;
java.time.format.DateTimeFormatter formatter = java.time.format.DateTimeFormatter.ofPattern("MM/dd/yyyy");
String formattedDate = date.format(formatter);


Table of Contents