1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
/* * Author: Akash Tyagi * Date:28Dec2017 * Detail: To explain use of Interface and Inheritance * in developing Core Selenium FW component in java for UI Operations * */ package _test; import org.openqa.selenium.WebElement; //Method List for all the Sync operations interface IUISync { //Default Method default public boolean waitForElementToAppear(WebElement element, int TimeOut){ return true; } //Default Method default public boolean waitForElementAttributeToAppear(WebElement element, String AttName, String ExpAttValue, int TimeOut){ return true; } //Default Method default public boolean waitForPageToLoad(int TimeOut){ return true; } //Default Method default public boolean waitForPageUrlToChange(String old_url, int TimeOut){ return true; } }//end Interface interface IUIEventsGeneric extends IUISync { //Default Methods in Generic UI events Interface default public String getText(WebElement element){ return element.getText(); } default public String getAttribute(WebElement element, String att_name){ return element.getAttribute(att_name); } }//end interface //Method List for all the Link Specific Operations interface IUIEventsLink { public void click(); }//end interface //Method List for all the Text Box Specific Operations interface IUIEventsTextBox{ public void sendKeys(String text); }//end interface //Method List for all the table specific operations interface IUIEventsTable { public String getTableContent(); public int getRowWithCellText(String s_text); }//end interface //UIMethods Class implements all the UI methods class UIMethods implements IUIEventsGeneric,IUIEventsLink,IUIEventsTextBox,IUIEventsTable,IUISync{ WebElement element; public UIMethods(WebElement obj){ this.element = obj; } public void click(){ waitForElementToAppear(element,10); element.click(); } public void sendKeys(String text){ element.sendKeys(text); } public String getTableContent(){ return getText(element); // Direct use of Default method from IUIEventsGeneric } public int getRowWithCellText(String s_text){ return 0; } }//End Class |