Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ide_script [2024/01/02 19:40] – [Code Assist] adminide_script [2024/01/02 19:49] (current) – [User Script] admin
Line 42: Line 42:
 ---- ----
 ==== Plugins ==== ==== Plugins ====
-//Plugins// extends the capability of //TestOptimal// to perform specialized operation.  They must be explicitly activated for the model in the scripts.+//Plugins// extends the capability of //TestOptimal// to perform specialized operation.  They are java class that implements a set of functions to be exposed to Script editor
  
-{{ wiki:idescreen:ide_script_plugin.png?450 }} 
- 
-Activated plugins will automatically added to code assist (Ctrl-Space). 
- 
-More info can be found at [[Plugins]] and [[http://testoptimal.com/v7/apidocs/ | System and Plugin Functions]]. 
  
 ---- ----
Line 110: Line 105:
 === Create Page Objects === === Create Page Objects ===
 Use the following script to create a new page object: Use the following script to create a new page object:
-   page1 = $SYS.addPage('MainPage'+   page1 = $PAGE.addPage('MainPage')
-   page1 = $SYS.getPageMgr().addPage('MainPage')+
  
  
Line 119: Line 113:
 Use the following script to add a page action to a page: Use the following script to add a page action to a page:
    page1.addAction('getPageSource', { page ->    page1.addAction('getPageSource', { page ->
-      $SYS.log('Getting page source for: ' + page.getName()); +      $EXEC.log('Getting page source for: ' + page.getName()); 
-      $SELENIUM.getWebDriver().findElement(By.tagName('body')).getText();+      $VAR.webdriver.findElement(By.tagName('body')).getText();
    })    })
 +
 +assuming that $VAR.webdriver has been assigned to WebDriver object that you have created.
  
 === Add Page Elements === === Add Page Elements ===
Line 129: Line 125:
 Use the following script to add a page element to a page: Use the following script to add a page element to a page:
    loginElem = page1.addElement('loginID');    loginElem = page1.addElement('loginID');
- 
      
 === Add Element Actions === === Add Element Actions ===
Line 137: Line 132:
 Use the following script to add an element action to an element: Use the following script to add an element action to an element:
    loginElem1.addAction('click', { elem, params ->    loginElem1.addAction('click', { elem, params ->
-     $SYS.log('Clicking on element ' + elem.getName() + ' on element locator: ' + elem.getLocator()); +     $EXEC.log('Clicking on element ' + elem.getName() + ' on element locator: ' + elem.getLocator()); 
-     $SELENIUM.getWebDriver().findElement(elem.getLocator()).click();+     $VAR.webdriver.findElement(elem.getLocator()).click();
    })    })
  
Line 145: Line 140:
    @TRIGGER('U1062')    @TRIGGER('U1062')
    def 'Start' () {    def 'Start' () {
-      $SYS.log('Page Source is: ' + $SYS.page('MainPage').perform('getPageSource')); +      $EXEC.log('Page Source is: ' + $SYS.page('MainPage').perform('getPageSource')); 
-      $SYS.page('MainPage').element('loginID').perform('click');+      $PAGE.page('MainPage').element('loginID').perform('click');
    }    }
  
Line 165: Line 160:
 //Steps// are annotated groovy functions as follows: //Steps// are annotated groovy functions as follows:
  
-   @STEP('Open {browserType} browser') 
-   def setBrowserType (String browserType) { 
-      $SELENIUM.setBrowserType(browserType); 
-   } 
-    
    @STEP('Goto URL {url}')    @STEP('Goto URL {url}')
    def gotoURL (String url) {    def gotoURL (String url) {
-      $SELENIUM.getWebDriver().get(url);+      $VAR.webdriver.get(url);
    }    }
        
    @STEP('Login with user id {userid} and password {password}')    @STEP('Login with user id {userid} and password {password}')
    def loginAs (String userid, String password) {    def loginAs (String userid, String password) {
-      $SELENIUM.getWebDriver().findElement(By.id('loginid')).sendKeys(userid); +      $VAR.webdriver.findElement(By.id('loginid')).sendKeys(userid); 
-      $SELENIUM.getWebDriver().findElement(By.id('password')).sendKeys(password);+      $VAR.webdriver.findElement(By.id('password')).sendKeys(password);
    }    }
        
Line 192: Line 182:
 Consider your model as a map to //GPS//, //MCase// is just a set of way points you want to visit. When you execute //MCase//, a sequence  path (trip/route) is auto-generated from your model. Consider your model as a map to //GPS//, //MCase// is just a set of way points you want to visit. When you execute //MCase//, a sequence  path (trip/route) is auto-generated from your model.
  
-   $SYS.getMCaseMgr().addMCase('MCase 1').navigateToState('V75Cents').executeTransition('add50', { state -> $SYS.log('MCase 1')}); +   $MCASE.addMCase('MCase 1').navigateToState('V75Cents').executeTransition('add50', { state -> $SYS.log('MCase 1')}); 
-   $SYS.getMCaseMgr().addMCase('MCase 3').navigateToState('V50Cents').executeTransition('add25', { state -> $SYS.log('MCase 3')}).skipToState('End');+   $MCASE.addMCase('MCase 3').navigateToState('V50Cents').executeTransition('add25', { state -> $SYS.log('MCase 3')}).skipToState('End');
  
 In additional to follow through path and execute the automation script (//TRIGGER//) along the path, you have the option to add additional automation/process script to be executed as illustrated in above example. In additional to follow through path and execute the automation script (//TRIGGER//) along the path, you have the option to add additional automation/process script to be executed as illustrated in above example.
Line 217: Line 207:
    @TRIGGER('U1062')    @TRIGGER('U1062')
    def 'Start' () {    def 'Start' () {
-      $SYS.log('adding 10 and 20: ' + $MyScript.add(10, 20)); +      $EXEC.log('adding 10 and 20: ' + $MyScript.add(10, 20)); 
-      $SYS.log('multiplying 10 and 20: ' + $MyScript.multiply(10, 20));+      $EXEC.log('multiplying 10 and 20: ' + $MyScript.multiply(10, 20));
    }    }