Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorial:scripting_state_model [2020/11/25 16:53]
admin [Activating plugins]
tutorial:scripting_state_model [2021/01/05 03:00] (current)
Line 37: Line 37:
  
  
-Besides triggers, scripts are also used for building UI Page Objects, Cucumber style test step definition and MCases, which are out of scope of this tutorial.  Please refer to [[../ide_script | Script Editor]] for more details.+Besides triggers, scripts are also used for building UI Page Objects, //Cucumber// style test step definition and //MCases//, which are out of scope of this tutorial.  Please refer to [[../ide_script | Script Editor]] for more details.
  
 ===== Model triggers ===== ===== Model triggers =====
Line 117: Line 117:
 For example: For example:
  
-   $SELENIUM.getWebDriver().findElement(org.openqa.selenium.By.id('Water').click();+   $SELENIUM.getWebDriver().findElement(org.openqa.selenium.By.id('DrinkWater').click();
  
 === Page Object===    === Page Object===   
Line 123: Line 123:
    //PAGES Script    //PAGES Script
    import org.openqa.selenium.By;    import org.openqa.selenium.By;
-   def addMainPage () { +   mainPage = $SYS.addPage('MainPage'
-      mainPage = $SYS.addPage('MainPage'+   elem = mainPage.addElement('DrinkWater', By.id('Water')) 
-      elem = mainPage.addElement('DrinkWater', By.id('Water')) +   elem.addAction('click', { elem, params -> 
-      elem.addAction('click', { elem, params -> +      $SELENIUM.getWebDriver().findElement(elem.locator).click(); 
-         $SELENIUM.getWebDriver().findElement(elem.locator).click(); +   })
-      }) +
-   } +
-   addMainPage()+
        
 Then in //TRIGGERS// tab, you can do this: Then in //TRIGGERS// tab, you can do this:
    $SYS.page('MainPage').element('DrinkWater').perform('click');    $SYS.page('MainPage').element('DrinkWater').perform('click');
        
 +The advantage of using page objects is that all element locators are organized and managed in one central place for easy maintenance.
 +
 === Find Element Locator === === Find Element Locator ===
 Web element locator can be xpath, css or by id, etc. as supported by //Selenium//. Web element locator can be xpath, css or by id, etc. as supported by //Selenium//.