vid-automation selenium tests
[vid.git] / vid-automation / src / main / java / vid / automation / test / infra / Exists.java
1 package vid.automation.test.infra;
2
3 import org.openqa.selenium.By;
4 import org.openqa.selenium.NoSuchElementException;
5 import org.openqa.selenium.WebElement;
6 import vid.automation.test.Constants;
7
8 public class Exists {
9     public static boolean byId(String id) {
10         return Get.byId(id) != null;
11     }
12
13     public static boolean byTestId(String testId) {
14         return Get.byTestId(testId) != null;
15     }
16
17     public static boolean byClass(String className) {
18         return Get.byClass(className) != null;
19     }
20
21     public static boolean byClassAndText(String className, String text) {
22         return Get.byClassAndText(className, text) != null;
23     }
24
25     public static boolean byCssSelectorAndText(String css, String text) {
26         return Get.byCssSelectorAndText(css, text) != null;
27     }
28
29     public static boolean modal() {
30         try {
31             return Get.byCssSelector(Constants.Modals.modalClass) != null;
32         } catch (NoSuchElementException exception) {
33             return false;
34         }
35     }
36
37     public static boolean tagNameInAnotherElement(WebElement parent, String tagName) {
38         try {
39             return parent.findElement(By.tagName(tagName)) != null;
40         } catch (NoSuchElementException exception) {
41             return false;
42         }
43     }
44 }