Differences

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

Link to this comparison view

power-agent:project-1:sahi [29/04/2015 14:43]
mathiasvandewalle [Script]
power-agent:project-1:sahi [13/05/2015 12:04] (current)
mathiasvandewalle [Mobile]
Line 67: Line 67:
 Sahi uses **Rhino engine** so Sahi script can call any java code in Sahi's classpath. Sahi uses **Rhino engine** so Sahi script can call any java code in Sahi's classpath.
 \\ Rhino seamlessly translates variables between Java and Javascript. \\ Rhino seamlessly translates variables between Java and Javascript.
 +\\ 
 +\\ The scripts are stored on the location where sahi is installed. 
 +\\ The folder Sahi_pro contains all the files to use sahi.
 +\\ Under this folder you find userdata where all the scripts are stored
 +
 ===== Using ===== ===== Using =====
 ==== Install ==== ==== Install ====
 Double click on install_sahi_pro_xxx.jar to start the installer. If Java is configured properly, it will launch the installer. Double click on install_sahi_pro_xxx.jar to start the installer. If Java is configured properly, it will launch the installer.
 \\ https://sahipro.com/docs/using-sahi/quick-tutorial.html \\ https://sahipro.com/docs/using-sahi/quick-tutorial.html
 +\\
 +\\ on **MAC**
 +\\ **start** sahi with \sahi_pro\userdata\bin\start_dashboard.sh
 +\\ Add **license** to \sahi_pro\userdata\config folder
 ==== Dashboard ==== ==== Dashboard ====
 {{:power-agent:project-1:sahi_dashboard.png?direct&100|}} The Sahi Dashboard automatically starts the Sahi proxy and lets you start your  configured browsers. {{:power-agent:project-1:sahi_dashboard.png?direct&100|}} The Sahi Dashboard automatically starts the Sahi proxy and lets you start your  configured browsers.
Line 293: Line 302:
  this.$url = "analyse.html";  this.$url = "analyse.html";
   
- this.go = function() { + this.go = function(){ _navigateTo(this.$url);}
- _navigateTo(this.$url); +
- }+
   
-        this.goMainMenu = function() { +        this.goMainMenu = function(){ this.clickTab("Hauptmenü");} 
- this.clickTab("Hauptmenü"); + this.clickTab = function($name){ _click(_span($name)); } 
-      //_span("x-tab-button") + this.closeTab = function($name){ _click(_span("/x-tab-close-btn/", _near(_span($name))));}
- } +
-     +
- this.clickTab = function($name) { +
-        _click(_span($name)); +
-       //_click(_link("/"+$name+"/")); +
- }+
   
- this.clickNewClient = function() { + this.clickNewClient = function(){ _click(_link("neueMandantButton"));} 
- _click(_link("neueMandantButton")); + this.clickEditClient = function(){ _click(_link("ladeMandantButton")); }
- }+
   
- this.clickEditClient = function() { + this.clientFilterByName = function($fname, $lname) { 
- _click(_link("ladeMandantButton"));+ _setValue(_textbox("vorname"), $fname); 
 + _setValue(_textbox("nachname"), $lname); 
 + _click(_span("Suche")); 
 + _wait(2000,!_isVisible(_div("Lade Daten...")) );
  }  }
   
Line 319: Line 322:
  _click(_div({className: "/x-boundlist-item/", sahiText : $item}));  _click(_div({className: "/x-boundlist-item/", sahiText : $item}));
         _click(_span("Suche"));         _click(_span("Suche"));
 +      _wait(2000,!_isVisible(_div("Lade Daten...")) );
 + }
 +
 + this.clickClient = function($fname,$lname) {
 + this.clientFilterByName($fname,$lname);
 + this.clickClientByName($fname,$lname);
  }  }
   
  this.clickClientByName = function($fname,$lname) {  this.clickClientByName = function($fname,$lname) {
- _doubleClick(_div($fname, _near(_div($lname))));+ $rows = _count("_row","/x-grid-row.*x-grid-data-row/"); // get all rows with clients visible 
 +      if($rows <= 0) _fail("no mandanten found"); 
 +      _log($rows + " rows found"); 
 +  
 +    for(var $i=0; $i<$rows; $i++)  { 
 +            $row = _row("/x-grid-row.*x-grid-data-row/["+$i+"]"); 
 + if($fname == _getCellText(_cell(0, _in($row))) && $lname ==  _getCellText(_cell(1, _in($row))) ){ //check firstname and lastname 
 + _doubleClick(_cell(0, _in($row))); 
 + return true; 
 +
 +
 + _fail("Mandant not found");
  }  }
   
  this.clickTabPersönlicheAngaben = function() {this.clickTab("Persönliche Angaben")}  this.clickTabPersönlicheAngaben = function() {this.clickTab("Persönliche Angaben")}
  this.clickTabVerträgeAngebote = function() {this.clickTab("Verträge & Angebote")}  this.clickTabVerträgeAngebote = function() {this.clickTab("Verträge & Angebote")}
 + this.clickTabBeratungHandlungsempfehlung = function() {this.clickTab("Beratung - Handlungsempfehlung")}
  this.clickTabAngebotsrechner = function() {this.clickTab("Angebotsrechner")}  this.clickTabAngebotsrechner = function() {this.clickTab("Angebotsrechner")}
- this.clickTabVergleichLotse = function() {this.clickTab("Vergleich Lotse")} 
  this.clickTabDokumente = function() {this.clickTab("Dokumente")}  this.clickTabDokumente = function() {this.clickTab("Dokumente")}
  this.clickTabWiedervorlagen = function() {this.clickTab("Wiedervorlagen")}  this.clickTabWiedervorlagen = function() {this.clickTab("Wiedervorlagen")}
- this.clickTabZieleWünsche = function() {this.clickTab("Ziele / Wünsche")} + this.clickTabKommunikation = function() {this.clickTab("Kommunikation")} 
- this.clickTabIhreErwartungenEmpfehlungen = function() {this.clickTab("Ihre Erwartungen Empfehlungen")}+  
 + this.deleteMandant = function($fname,$lname){ //start from main menu 
 + this.clientFilterByName($fname,$lname); 
 + $rows = _count("_row","/x-grid-row.*x-grid-data-row/")
 + _log($rows + " rows found"); 
 + for(var $i=0; $i<$rows; $i++)  { 
 +            $row = _row("/x-grid-row.*x-grid-data-row/["+$i+"]"); 
 + if($fname == _getCellText(_cell(0, _in($row))) && $lname ==  _getCellText(_cell(1, _in($row))) ){ //check firstname and lastname 
 + _click(_image("user_delete.png", _in($row))); //delete row 
 + _assertVisible(_span("Achtung")); 
 + _click(_link("Ja")); 
 +
 +
 + _click(_image("x-tool-img x-tool-close")); // close window 
 + }
   
 } }
  
-function clickFormTrigger($inputElName){+function clickFormTrigger($inputElName){ // dropdown or calender icon
  _click(_div("/ x-form-trigger /", _near(_textbox($inputElName))));  _click(_div("/ x-form-trigger /", _near(_textbox($inputElName))));
 } }
Line 343: Line 377:
  clickFormTrigger($inputElName);  clickFormTrigger($inputElName);
  _click(_listItem($item));  _click(_listItem($item));
 +}
 +
 +function checkFieldRequired($inputElName) {
 + _assertEqual("/x-form-required-field/", _textbox($inputElName).className);  
 +}
 +
 +function checkFieldDisabled($inputElName) {
 + _assertEqual(true, _textbox($inputElName).disabled);
 } }
  </code>  </code>
-<code java testFormHundehalter.sah>_include("../login/login_lib.sah");+<code java createMandant.sah>_include("../../login/login_lib.sah");
 login("jcpadmin","test"); login("jcpadmin","test");
-_include("../pages/analysePage.sah"); 
-$analysePage = new AnalysePage(); 
  
-$analysePage.clickEditClient(); +_include(";../../pages/analysePage.sah"); 
-$analysePage.clickClientByName("Tom";,"Tester";);+$ap = new AnalysePage(); 
 +$ap.go();
  
-_doubleClick(_div("Hundehalter")); +//------------------------------------------ 
-_assertEqual("Hundehalterversicherung", _getText(_div("myBausteinTitle")));+// test create Mandant 
 +//------------------------------------------
  
-// start form +//---delete all "Test Testerif exists ---- 
-clickFormTrigger("angebotsType"); //click dropdown icon in dropdownmenu +$ap.clickEditClient(); 
-_click(_listItem("Vertrag"));     // click the item in the dropdownlist +$ap.deleteMandant("Test Tester","Sahi");
-                                  // by using _setStrictVisibilityCheck(true); sahi will only check visible items +
-                                  // there can only be one dropdownlist shown. +
-//or setDropdownItem("angebotsType","Vertrag"); +
-_click(_button("Eigenvertrag:")); //checkbox +
-_click(_button("Unterlagen mitgenommen:")); // checkboxes don't have a name +
-                                            // using the label near it to select the checkbox +
  
-_setValue(_textbox("name"), "testname"); // setValue for textbox / text inputfields +//-----------create new (required)----- 
-_setValue(_textbox("beschreibung"), "testbeschreibung");+$ap.clickNewClient();
  
-clickFormTrigger("mp"); +checkFieldRequired("vorname"); 
-_click(_listItem("P: tess de tester"));+_setValue(_textbox("vorname"), "Test Tester");
  
-_setValue(_textbox("gesellschaft"), "VersicherungsAG"); +checkFieldRequired("nachname"); 
-_setValue(_textbox("versicherungsnummer"), "002");+_setValue(_textbox("nachname"), "Sahi");
  
-clickFormTrigger("tarifgruppe"); +_setValue(_textbox("geburtsdatum"), "01.01.1990"); 
-_click(_listItem("Innendienst"));+checkFieldRequired("geburtsdatum");
  
-clickFormTrigger("kampfhund"); +_click(_span("Speichern")); 
-_click(_listItem("Ja"));</code>+ 
 +//-------------Haushalt---------------- 
 +//------Kunde------------------------ 
 +_click(_div("Kunde")); 
 +_setValue(_textbox("strasse"), "Sahistraße"); 
 +_setValue(_textbox("hausnummer"), "1"); 
 +_click(_span("Änderungen speichern")); 
 + 
 +//------Partner------------------------ 
 +_click(_div("Partner")); 
 +_setValue(_textbox("vorname"), "Test Partner"); 
 +_setValue(_textbox("nachname"), "Sahi"); 
 +_setValue(_textbox("geburtsdatum"), "02.01.1990"); 
 +_click(_span("Änderungen speichern")); 
 + 
 +//-----Kinder----------- 
 +_click(_div("Kinder")); 
 + 
 +_click(_span("Neue")); 
 +_setValue(_textbox("vorname"), "Test Junior"); 
 +_setValue(_textbox("nachname"), "Sahi"); 
 +_setValue(_textbox("geburtsdatum"), "01.01.2015"); 
 +_click(_span("Änderungen speichern")); 
 + 
 +_click(_span("Neue")); 
 +clickFormTrigger("anrede"); 
 +_click(_listItem("weiblich")); 
 +_setValue(_textbox("vorname"), "Test Kinder"); 
 +_setValue(_textbox("nachname"), "Sahi"); 
 +_setValue(_textbox("geburtsdatum"), "02.01.2015"); 
 +_click(_span("Änderungen speichern")); 
 +</code> 
 +<code java testKunde.sah>_include("../../pages/analysePage.sah"); 
 +$ap = new AnalysePage(); 
 +$ap.go(); 
 + 
 +$ap.clickEditClient(); 
 +$ap.clickClient("Test Tester","Sahi"); 
 + 
 +$ap.clickTabPersönlicheAngaben(); 
 + 
 +//------------------------------------------ 
 +// test Kunde 
 +//------------------------------------------ 
 + 
 +//-------------Person---------------------- 
 +_click(_div("Kunde")); 
 + 
 +_assertEqual("Torsten B", _getValue(_textbox("beraterId"))); 
 + 
 +_assertEqual("Herr", _getValue(_textbox("anrede"))); 
 +checkFieldRequired("anrede"); 
 + 
 +_assertEqual("Test Tester", _getValue(_textbox("vorname"))); 
 +checkFieldRequired("vorname"); 
 + 
 +_assertEqual("Sahi", _getValue(_textbox("nachname"))); 
 +checkFieldRequired("nachname"); 
 + 
 +_assertEqual("01.01.1990", _getValue(_textbox("geburtsdatum"))); 
 +checkFieldRequired("geburtsdatum"); 
 + 
 +_assertEqual("Sahistraße", _getValue(_textbox("strasse"))); 
 + 
 +//-------------Ausbildung/Beruf------------ 
 +_click(_span("Ausbildung/Beruf")); 
 +//_assertEqual("Angestellte/r", _getValue(_textbox("beschaeftigungsverhaeltnis"))); 
 + 
 +//-------------Arbeitgeber------------------- 
 +_click(_span("Arbeitgeber")); 
 + 
 +//-------------Kommunikation--------------- 
 +_click(_span("Kommunikation", _near(_span("Kunde")))); 
 + 
 +//_assertEqual("VersicherungsAG", _getValue(_textbox("contactVersicherungen"))); 
 +//_assertEqual("BankAG", _getValue(_textbox("contactBank"))); 
 +//_assertEqual("SteuerAG", _getValue(_textbox("contactSteuern"))); 
 +//_assertEqual("RechtsAG", _getValue(_textbox("contactRecht"))); 
 + 
 +//-------------Legitimation------------------ 
 +_click(_span("Legitimation")); 
 + 
 +//-------------Bank-------------------------- 
 +_click(_span("Bank")); 
 + 
 +//_assertEqual("BankAG", _getValue(_textbox("bank0"))); 
 + 
 +//-------------Gesundheit-------------------- 
 +_click(_span("Gesundheit")); 
 + 
 +//_assertEqual("193", _getValue(_textbox("grosse"))); 
 +//_assertEqual("89", _getValue(_textbox("gewicht"))); 
 +//_assertEqual("Nein", _getValue(_textbox("motorradfahrer"))); 
 + 
 +//-------------Erweiterte Berufsfragen------ 
 +_click(_span("Erweiterte Berufsfragen")); 
 + 
 +_assertEqual("Sonstige Berufsausbildung", _getValue(_textbox("eb_abgeschlosseneAusbildung"))); 
 + 
 +//-------------Steuern------------------------ 
 +_click(_span("Steuern")); 
 + 
 +//_assertEqual("1", _getValue(_textbox("steuerklasse")));</code>
  
 **TestSuite** **TestSuite**
Line 397: Line 535:
 \\ You can also make custom reports.  \\ You can also make custom reports. 
  
 +==== Mobile ====
 +configure sahi proxy https://sahipro.com/docs/using-sahi/playback-mobile.html
 +\\ 
 +\\ Use the safari debug tools.
 +\\ Because the app uses a local file for the app the proxy is not used.
 +\\ 
 +\\ We will need to change the location to your webserver and run the tests.
 +\\ change the location to your proxy ex.: ''location.href = "http://192.168.4.6:9999";''
 +\\ Now you see the sahi start page where you can insert the test you want to run and the url of you webserver.
 +\\ you can also use the command line to start the test.
 +<code java>$("filebox").value = "mobile/test3.sah";
 +$("starturl").value = "http://192.168.4.6:8080/Finanzanalyse.app/www";
 +launch();
 +
 +OR
  
 +_sahi.sendToServer("_s_/dyn/Player_setScriptFile?dir=C%3A%2FUsers%2Fmathias%2Fsahi_pro%2Fuserdata%2Fscripts%2F&file="+"mobile/test3.sah"+"&starturl="+"http://192.168.4.6:8080/Finanzanalyse.app/www"+"&manual=0"+"&browserType=Netscape");
 +_sahi.setServerVar("sahi_paused", "0");</code>