Differences
This shows you the differences between two versions of the page.
|
power-agent:project-1:sahi [28/04/2015 15:53] mathiasvandewalle [API] |
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 84: | Line 93: | ||
| \\ You can choose alternatives and actions to use. | \\ You can choose alternatives and actions to use. | ||
| \\ Using the arrow you can go to the parent node and you can anchor to this element by clicking the anchor button. | \\ Using the arrow you can go to the parent node and you can anchor to this element by clicking the anchor button. | ||
| - | \\ If you now select an other element sahi will use _in, _near API to find your element. [[sahi#API]] | + | \\ If you now select an other element sahi will use _in, _near API to find your element. |
| \\ https://sahipro.com/docs/using-sahi/sahi-controller.html | \\ https://sahipro.com/docs/using-sahi/sahi-controller.html | ||
| ==== Editor ==== | ==== Editor ==== | ||
| Line 96: | Line 105: | ||
| ==== API ==== | ==== API ==== | ||
| - | https://sahipro.com/docs/sahi-apis/index.html | ||
| - | |||
| === Accessor API Basics === | === Accessor API Basics === | ||
| | _link(12)|Using index in the page; assuming it is the 13th link on the page. | | | _link(12)|Using index in the page; assuming it is the 13th link on the page. | | ||
| Line 176: | Line 183: | ||
| * _keyPress | * _keyPress | ||
| * _type | * _type | ||
| - | More Actions: https://sahipro.com/docs/sahi-apis/action-apis.html | + | **More Actions:** https://sahipro.com/docs/sahi-apis/action-apis.html |
| \\ Focus Events | \\ Focus Events | ||
| \\ Text Selection | \\ Text Selection | ||
| Line 187: | Line 194: | ||
| \\ Calling Generic Code | \\ Calling Generic Code | ||
| \\ | \\ | ||
| - | \\ **More APIs:** | + | \\ **More APIs:** https://sahipro.com/docs/sahi-apis/index.html |
| \\ Relation APIs | \\ Relation APIs | ||
| \\ Screenshot APIs | \\ Screenshot APIs | ||
| Line 295: | 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 321: | 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 345: | 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 Tester" if 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** | ||
| + | <code java testsuite.suite>test/login/testlogin.s.csv | ||
| + | test/login/testlogin.dd.csv | ||
| + | test/analyse/TestTabs.sah | ||
| + | test/analyse/TestNewMandant.sah | ||
| + | test/analyse/TestFormHundehalter.sah</code> | ||
| + | |||
| + | Data driven test: | ||
| + | \\ {{:power-agent:project-1:sahi_script_dd.csv.png|}} | ||
| + | \\ You can set the start url, add tags and pass parameters. | ||
| + | \\ If you want to run only tests with a specific tag, you can configure that at playback. | ||
| + | ==== Reports ==== | ||
| + | {{:power-agent:project-1:sahi_reports_root.png?direct&200|}}{{:power-agent:project-1:sahi_reports_compare.png?direct&250|}}{{:power-agent:project-1:sahi_reports_script.png?direct&200|}} | ||
| + | \\ You can see all the test that you ran, filter, compare test and screenshots, see details. | ||
| + | \\ 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> | ||