@@ -1061,6 +1061,13 @@ public static void scrollToElement(By element) {
10611061 js .executeScript ("arguments[0].scrollIntoView(true);" , getWebElement (element ));
10621062 }
10631063
1064+ public static void scrollToElement (WebElement element ) {
1065+ smartWait ();
1066+
1067+ JavascriptExecutor js = (JavascriptExecutor ) DriverManager .getDriver ();
1068+ js .executeScript ("arguments[0].scrollIntoView(true);" , element );
1069+ }
1070+
10641071 public static void scrollToPosition (int X , int Y ) {
10651072 smartWait ();
10661073
@@ -1463,7 +1470,34 @@ public static String getTagNameElement(By by) {
14631470 //Handle Table
14641471
14651472 /**
1466- * Kiểm tra giá trị từng cột của table khi tìm kiếm theo điều kiện CHỨA
1473+ * Kiểm tra giá trị từng cột của table khi tìm kiếm theo điều kiện BẰNG (equals)
1474+ *
1475+ * @param column vị trí cột
1476+ * @param value giá trị cần so sánh
1477+ */
1478+ @ Step ("Check data by EQUALS type after searching on the Table by Column." )
1479+ public static void checkEqualsSearchTableByColumn (int column , String value ) {
1480+ smartWait ();
1481+ sleep (1 );
1482+ List <WebElement > totalRows = getWebElements (By .xpath ("//tbody/tr" ));
1483+ Log .info ("Number of results for keyword (" + value + "): " + totalRows .size ());
1484+
1485+ if (totalRows .size () < 1 ) {
1486+ Log .info ("Not found value: " + value );
1487+ } else {
1488+ for (int i = 1 ; i <= totalRows .size (); i ++) {
1489+ boolean res = false ;
1490+ WebElement title = waitForElementPresent (By .xpath ("//tbody/tr[" + i + "]/td[" + column + "]" ));
1491+ WebUI .scrollToElement (title );
1492+ res = title .getText ().toUpperCase ().equals (value .toUpperCase ());
1493+ Log .info ("Row " + i + ": " + res + " - " + title .getText ());
1494+ Assert .assertTrue (res , "Row " + i + " (" + title .getText () + ")" + " equals no value: " + value );
1495+ }
1496+ }
1497+ }
1498+
1499+ /**
1500+ * Kiểm tra giá trị từng cột của table khi tìm kiếm theo điều kiện CHỨA (contains)
14671501 *
14681502 * @param column vị trí cột
14691503 * @param value giá trị cần so sánh
@@ -1472,7 +1506,6 @@ public static String getTagNameElement(By by) {
14721506 public static void checkContainsSearchTableByColumn (int column , String value ) {
14731507 smartWait ();
14741508 sleep (1 );
1475- JavascriptExecutor js = (JavascriptExecutor ) DriverManager .getDriver ();
14761509 List <WebElement > totalRows = getWebElements (By .xpath ("//tbody/tr" ));
14771510 Log .info ("Number of results for keyword (" + value + "): " + totalRows .size ());
14781511
@@ -1482,7 +1515,7 @@ public static void checkContainsSearchTableByColumn(int column, String value) {
14821515 for (int i = 1 ; i <= totalRows .size (); i ++) {
14831516 boolean res = false ;
14841517 WebElement title = waitForElementPresent (By .xpath ("//tbody/tr[" + i + "]/td[" + column + "]" ));
1485- js . executeScript ( "arguments[0].scrollIntoView(true);" , title );
1518+ WebUI . scrollToElement ( title );
14861519 res = title .getText ().toUpperCase ().contains (value .toUpperCase ());
14871520 Log .info ("Row " + i + ": " + res + " - " + title .getText ());
14881521 Assert .assertTrue (res , "Row " + i + " (" + title .getText () + ")" + " contains no value: " + value );
@@ -1502,7 +1535,6 @@ public static void checkContainsSearchTableByColumn(int column, String value, St
15021535 smartWait ();
15031536
15041537 //xpathToTRtagname is locator from table to "tr" tagname of data section: //tbody/tr, //div[@id='example_wrapper']//tbody/tr, ...
1505- JavascriptExecutor js = (JavascriptExecutor ) DriverManager .getDriver ();
15061538 List <WebElement > totalRows = DriverManager .getDriver ().findElements (By .xpath (xpathToTRtagname ));
15071539 sleep (1 );
15081540 Log .info ("Number of results for keyword (" + value + "): " + totalRows .size ());
@@ -1513,7 +1545,7 @@ public static void checkContainsSearchTableByColumn(int column, String value, St
15131545 for (int i = 1 ; i <= totalRows .size (); i ++) {
15141546 boolean res = false ;
15151547 WebElement title = DriverManager .getDriver ().findElement (By .xpath (xpathToTRtagname + "[" + i + "]/td[" + column + "]" ));
1516- js . executeScript ( "arguments[0].scrollIntoView(true);" , title );
1548+ WebUI . scrollToElement ( title );
15171549 res = title .getText ().toUpperCase ().contains (value .toUpperCase ());
15181550 Log .info ("Row " + i + ": " + res + " - " + title .getText ());
15191551 Assert .assertTrue (res , "Row " + i + " (" + title .getText () + ")" + " contains no value " + value );
@@ -1588,8 +1620,8 @@ public static WebElement waitForElementVisible(By by, long timeOut) {
15881620 */
15891621 public static WebElement waitForElementVisible (By by ) {
15901622 smartWait ();
1591-
15921623 waitForElementPresent (by );
1624+
15931625 try {
15941626 WebDriverWait wait = new WebDriverWait (DriverManager .getDriver (), Duration .ofSeconds (WAIT_EXPLICIT ), Duration .ofMillis (500 ));
15951627 boolean check = verifyElementVisible (by );
0 commit comments