33 * Automation Framework Selenium
44 */
55
6- package anhtester .com .keyword ;
6+ package anhtester .com .keywords ;
77
88import anhtester .com .constants .FrameworkConstants ;
99import anhtester .com .driver .DriverManager ;
@@ -589,27 +589,27 @@ public static void uploadFileWithSendKeys(By by, String filePath) {
589589 @ Step ("Get Current URL" )
590590 public static String getCurrentUrl () {
591591 smartWait ();
592- Log .info ("Current Page Url : " + DriverManager .getDriver ().getCurrentUrl ());
592+ Log .info ("Get Current URL : " + DriverManager .getDriver ().getCurrentUrl ());
593593 if (ExtentTestManager .getExtentTest () != null ) {
594- ExtentReportManager .info ("Current Page Url : " + DriverManager .getDriver ().getCurrentUrl ());
594+ ExtentReportManager .info ("Get Current URL : " + DriverManager .getDriver ().getCurrentUrl ());
595595 }
596- AllureManager .saveTextLog ("Current Page Url : " + DriverManager .getDriver ().getCurrentUrl ());
596+ AllureManager .saveTextLog ("Get Current URL : " + DriverManager .getDriver ().getCurrentUrl ());
597597 return DriverManager .getDriver ().getCurrentUrl ();
598598 }
599599
600600 @ Step ("Get Page Title" )
601601 public static String getPageTitle () {
602602 smartWait ();
603603 String title = DriverManager .getDriver ().getTitle ();
604- Log .info ("Current Page Title: " + DriverManager .getDriver ().getTitle ());
604+ Log .info ("Get Page Title: " + DriverManager .getDriver ().getTitle ());
605605 if (ExtentTestManager .getExtentTest () != null ) {
606- ExtentReportManager .info ("Get Current Page Title: " + DriverManager .getDriver ().getTitle ());
606+ ExtentReportManager .info ("Get Page Title: " + DriverManager .getDriver ().getTitle ());
607607 }
608- AllureManager .saveTextLog ("Get Current Page Title: " + DriverManager .getDriver ().getTitle ());
608+ AllureManager .saveTextLog ("Get Page Title: " + DriverManager .getDriver ().getTitle ());
609609 return title ;
610610 }
611611
612- public static boolean verifyPageTitle (String pageTitle ) {
612+ public static boolean getPageTitle (String pageTitle ) {
613613 smartWait ();
614614 return getPageTitle ().equals (pageTitle );
615615 }
@@ -619,13 +619,6 @@ public static boolean verifyPageContainsText(String text) {
619619 return DriverManager .getDriver ().getPageSource ().contains (text );
620620 }
621621
622- @ Step ("Verify Page Url {0}" )
623- public static boolean verifyPageUrl (String pageUrl ) {
624- smartWait ();
625- Log .info ("Current URL: " + DriverManager .getDriver ().getCurrentUrl ());
626- return DriverManager .getDriver ().getCurrentUrl ().contains (pageUrl .trim ());
627- }
628-
629622 //Handle checkbox and radio button
630623
631624 public static boolean verifyElementChecked (By by ) {
@@ -922,6 +915,128 @@ public static boolean verifyElementExists(By by) {
922915 return res ;
923916 }
924917
918+ @ Step ("Verify Equals: {0} ---AND--- {1}" )
919+ public static boolean verifyEquals (Object value1 , Object value2 ) {
920+ boolean result = value1 .equals (value2 );
921+ if (result == true ) {
922+ Log .info ("Verify Equals: " + value1 + " = " + value2 );
923+ if (ExtentTestManager .getExtentTest () != null ) {
924+ ExtentReportManager .pass ("Verify Equals: " + value1 + " = " + value2 );
925+ }
926+ AllureManager .saveTextLog ("Verify Equals: " + value1 + " = " + value2 );
927+ } else {
928+ Log .info ("Verify Equals: " + value1 + " != " + value2 );
929+ if (ExtentTestManager .getExtentTest () != null ) {
930+ ExtentReportManager .fail ("Verify Equals: " + value1 + " != " + value2 );
931+ }
932+ AllureManager .saveTextLog ("Verify Equals: " + value1 + " != " + value2 );
933+ Assert .assertEquals (value1 , value2 , value1 + " != " + value2 );
934+ }
935+ return result ;
936+ }
937+
938+ @ Step ("Verify Equals: {0} ---AND--- {1}" )
939+ public static boolean verifyEquals (Object value1 , Object value2 , String message ) {
940+ boolean result = value1 .equals (value2 );
941+ if (result == true ) {
942+ Log .info ("Verify Equals: " + value1 + " = " + value2 );
943+ if (ExtentTestManager .getExtentTest () != null ) {
944+ ExtentReportManager .pass ("Verify Equals: " + value1 + " = " + value2 );
945+ }
946+ AllureManager .saveTextLog ("Verify Equals: " + value1 + " = " + value2 );
947+ } else {
948+ Log .info ("Verify Equals: " + value1 + " != " + value2 );
949+ if (ExtentTestManager .getExtentTest () != null ) {
950+ ExtentReportManager .fail ("Verify Equals: " + value1 + " != " + value2 );
951+ }
952+ AllureManager .saveTextLog ("Verify Equals: " + value1 + " != " + value2 );
953+ Assert .assertEquals (value1 , value2 , message );
954+ }
955+ return result ;
956+ }
957+
958+ @ Step ("Verify Contains: {0} ---AND--- {1}" )
959+ public static boolean verifyContains (String value1 , String value2 ) {
960+ boolean result = value1 .contains (value2 );
961+ if (result == true ) {
962+ Log .info ("Verify Equals: " + value1 + " CONTAINS " + value2 );
963+ if (ExtentTestManager .getExtentTest () != null ) {
964+ ExtentReportManager .pass ("Verify Contains: " + value1 + " CONTAINS " + value2 );
965+ }
966+ AllureManager .saveTextLog ("Verify Contains: " + value1 + "CONTAINS" + value2 );
967+ } else {
968+ Log .info ("Verify Contains: " + value1 + " NOT CONTAINS " + value2 );
969+ if (ExtentTestManager .getExtentTest () != null ) {
970+ ExtentReportManager .fail ("Verify Contains: " + value1 + " NOT CONTAINS " + value2 );
971+ }
972+ AllureManager .saveTextLog ("Verify Contains: " + value1 + " NOT CONTAINS " + value2 );
973+
974+ Assert .assertEquals (value1 , value2 , value1 + " NOT CONTAINS " + value2 );
975+ }
976+ return result ;
977+ }
978+
979+ @ Step ("Verify Contains: {0} ---AND--- {1}" )
980+ public static boolean verifyContains (String value1 , String value2 , String message ) {
981+ boolean result = value1 .contains (value2 );
982+ if (result == true ) {
983+ Log .info ("Verify Equals: " + value1 + " CONTAINS " + value2 );
984+ if (ExtentTestManager .getExtentTest () != null ) {
985+ ExtentReportManager .pass ("Verify Contains: " + value1 + " CONTAINS " + value2 );
986+ }
987+ AllureManager .saveTextLog ("Verify Contains: " + value1 + "CONTAINS" + value2 );
988+ } else {
989+ Log .info ("Verify Contains: " + value1 + " NOT CONTAINS " + value2 );
990+ if (ExtentTestManager .getExtentTest () != null ) {
991+ ExtentReportManager .fail ("Verify Contains: " + value1 + " NOT CONTAINS " + value2 );
992+ }
993+ AllureManager .saveTextLog ("Verify Contains: " + value1 + " NOT CONTAINS " + value2 );
994+
995+ Assert .assertEquals (value1 , value2 , message );
996+ }
997+ return result ;
998+ }
999+
1000+ @ Step ("Verify TRUE with condition: {0}" )
1001+ public static boolean verifyTrue (Boolean condition ) {
1002+ if (condition == true ) {
1003+ Log .info ("Verify TRUE: " + condition );
1004+ if (ExtentTestManager .getExtentTest () != null ) {
1005+ ExtentReportManager .pass ("Verify TRUE: " + condition );
1006+ }
1007+ AllureManager .saveTextLog ("Verify TRUE: " + condition );
1008+ } else {
1009+ Log .info ("Verify TRUE: " + condition );
1010+ if (ExtentTestManager .getExtentTest () != null ) {
1011+ ExtentReportManager .fail ("Verify TRUE: " + condition );
1012+ }
1013+ AllureManager .saveTextLog ("Verify TRUE: " + condition );
1014+
1015+ Assert .assertTrue (condition , "The condition is FALSE." );
1016+ }
1017+ return condition ;
1018+ }
1019+
1020+ @ Step ("Verify TRUE with condition: {0}" )
1021+ public static boolean verifyTrue (Boolean condition , String message ) {
1022+ if (condition == true ) {
1023+ Log .info ("Verify TRUE: " + condition );
1024+ if (ExtentTestManager .getExtentTest () != null ) {
1025+ ExtentReportManager .pass ("Verify TRUE: " + condition );
1026+ }
1027+ AllureManager .saveTextLog ("Verify TRUE: " + condition );
1028+ } else {
1029+ Log .info ("Verify TRUE: " + condition );
1030+ if (ExtentTestManager .getExtentTest () != null ) {
1031+ ExtentReportManager .fail ("Verify TRUE: " + condition );
1032+ }
1033+ AllureManager .saveTextLog ("Verify TRUE: " + condition );
1034+
1035+ Assert .assertTrue (condition , message );
1036+ }
1037+ return condition ;
1038+ }
1039+
9251040 public static boolean verifyElementText (By by , String text ) {
9261041 smartWait ();
9271042 waitForElementVisible (by );
@@ -1917,7 +2032,7 @@ public static void checkEqualsValueOnTableByColumn(int column, String value) {
19172032 smartWait ();
19182033 sleep (1 );
19192034 List <WebElement > totalRows = getWebElements (By .xpath ("//tbody/tr" ));
1920- Log .info ("Number of results for keyword (" + value + "): " + totalRows .size ());
2035+ Log .info ("Number of results for keywords (" + value + "): " + totalRows .size ());
19212036
19222037 if (totalRows .size () < 1 ) {
19232038 Log .info ("Not found value: " + value );
@@ -1943,7 +2058,7 @@ public static void checkContainsValueOnTableByColumn(int column, String value) {
19432058 smartWait ();
19442059 sleep (1 );
19452060 List <WebElement > totalRows = getWebElements (By .xpath ("//tbody/tr" ));
1946- Log .info ("Number of results for keyword (" + value + "): " + totalRows .size ());
2061+ Log .info ("Number of results for keywords (" + value + "): " + totalRows .size ());
19472062
19482063 if (totalRows .size () < 1 ) {
19492064 Log .info ("Not found value: " + value );
@@ -1972,7 +2087,7 @@ public static void checkContainsValueOnTableByColumn(int column, String value, S
19722087 //xpathToTRtagname is locator from table to "tr" tagname of data section: //tbody/tr, //div[@id='example_wrapper']//tbody/tr, ...
19732088 List <WebElement > totalRows = DriverManager .getDriver ().findElements (By .xpath (xpathToTRtagname ));
19742089 sleep (1 );
1975- Log .info ("Number of results for keyword (" + value + "): " + totalRows .size ());
2090+ Log .info ("Number of results for keywords (" + value + "): " + totalRows .size ());
19762091
19772092 if (totalRows .size () < 1 ) {
19782093 Log .info ("Not found value: " + value );
0 commit comments