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 [2020/05/28 02:10] – [ShortCut Keys] adminide_script [2024/01/02 19:49] (current) – [User Script] admin
Line 10: Line 10:
   * auto formatting   * auto formatting
   * code collapse   * code collapse
-  * code assist+  * [[#code assist]]
   * search   * search
   * replace   * replace
Line 16: Line 16:
  
 The tool pallet on the upper-right corner of the editor gives you quick access to common editor features. The tool pallet on the upper-right corner of the editor gives you quick access to common editor features.
- 
 {{ wiki:idescreen:ide_script_toolbar.png? 150 }} {{ wiki:idescreen:ide_script_toolbar.png? 150 }}
  
Line 24: Line 23:
  
 ---- ----
-==== Plugins ==== 
-//Plugins// extends the capability of //TestOptimal// to perform specialized operation.  They must be explicitly activated for the model in the scripts. 
  
-{{ wiki:idescreen:ide_script_plugin.png?450 }}+==== Code Assist ==== 
 +Code assist is supported on [[https://testoptimal.com/v7/apidocs/|system functions and plugin functions]], which includes your own custom plugins.
  
-Activated plugins will automatically added to code assist (Ctrl-Space).+Code assist can be opened with //Ctrl-Space// in one of the following: 
 +  * on a blank line or after a "$" 
 + 
 +{{wiki:idescreen:ide_script_ca.png? 80}} 
 + 
 +  * on chained system or plugin function calls 
 + 
 +{{wiki:idescreen:ide_script_ca_sys.png? 270}} 
 + 
 +  * on java classes 
 + 
 +{{wiki:idescreen:ide_script_ca_javaclass.png? 225}} 
 + 
 +---- 
 +==== Plugins ==== 
 +//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
  
-More info can be found at [[Plugins]] and [[http://testoptimal.com/v6/apidocs/ | System and Plugin Functions]]. 
  
 ---- ----
Line 93: 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 102: 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 112: 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 120: 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 128: 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 148: 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 171: Line 178:
 //MCASE Script// is where //MCase// are defined. //MCASE Script// is where //MCase// are defined.
  
-//MCase// is a custom test case / workflow that you defined explicitly for the system to generate a sequence path from the model to achieve specific scenario. +Often times you may have a set of specific test scenarios you want to make sure are covered to complement the system generated test cases.  You can achieve just that with //MCase// -  a custom test case / workflow that you defined explicitly for the system to generate a sequence path from the model to achieve specific scenario. 
  
 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 184: Line 191:
 ---- ----
 ==== User Script ==== ==== User Script ====
-Besides [[#TRIGGER Script]], [[#PAGES Sript]] and [[#STEPS Script]], you may also add additional scripts.+Besides [[#TRIGGER Script]], [[#PAGES Sript]][[#STEPS Script]] and [[#MCASE Script]], you may also add additional scripts.
  
 To create a user script, click on "+" You can rename the script by clicking on the pencil mini-button. To create a user script, click on "+" You can rename the script by clicking on the pencil mini-button.
Line 200: 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));
    }    }
 +
 +----
 +==== Include File ====
 +You may include script file into your TRIGGER script.  Just add the @INCLUDE_FILE below:
 +   @INCLUDE_FILE 'absolute file path to include file'
 +
 +The above script will literally inject the content of the included file into current script before TRIGGER script is executed.  
 +
 +The side effect of using this INCLUDE_FILE is that the injected scripts will mess up the script line # reported on errors.
  
 ---- ----
Line 229: Line 245:
   * **Ctrl-]** / //Cmd-]//: shift line to the right (indent)   * **Ctrl-]** / //Cmd-]//: shift line to the right (indent)
  
-Except for **Ctrl-R / Ctrl-I** for windows and //Cmd-R / Cmd-I// for Mac, check out [[https://codemirror.net/doc/manual.html | CodeMirror]] for official key mappings.+Except for **Ctrl-R / Ctrl-I** for windows and //Cmd-R / Cmd-I// for Mac, check out [[https://codemirror.net/doc/manual.html#commands | CodeMirror Commands]] for additional key mappings and details of mapped commands.