In the browser configuration, add this flag:
--ignore-certificate-errors This will cause Chrome to start up with a yellow ribbon, warning you of insecurity, but it will allow Sahi to run again
0 Comments
To add an extension to Chrome, such as the HYFY video recorder, it will be necessary to remove this from the browser configuration temporarily: --proxy-server=127.0.0.1:9999 from <option>
Sahi's support provided me with the following information: Please follow the steps below in order to add the extension in Chrome profile in Sahi. 1) Start Sahi and click on configure link present on the Sahi Dashboard. 2) Click on browser_types.xml 3) Go to <browserType> chrome. 4) In <browserType> chrome you will find an <option> tag something like below. <options>--user-data-dir=$userDir\browser\chrome\profiles\sahi$threadNo --proxy-server=127.0.0.1:9999 --always-authorize-plugins --allow-outdated-plugins --enable-npapi --incognito</options> 5) Remove the --proxy-server=127.0.0.1:9999 from <option>. After removing the line it should look like something like below. <options>--user-data-dir=$userDir\browser\chrome\profiles\sahi$threadNo --always-authorize-plugins --allow-outdated-plugins --enable-npapi --incognito</options> 6) After making the changes. Save the file and restart Sahi. 7) Start Sahi and open the chrome browser, you will not able to see the start page of Sahi. Install the chrome extension and make the extension to show in incognito mode. 8) Close the browser and close Sahi. 9) Go to <SahiPro>\userdata\browser\chrome\profiles folder. You will see the folders like sahi0,sahi1,sahi2,sahi3,sahi4. 10) Take the backup of all the folder and Delete all the folders except sahi0. Note: Please don't delete the sahi0 folder. 11) After deleting the folders. Copy the sahi0 folder four times in the same location and rename the folders to sahi1,sahi2,sahi3,sahi4. 12) Start Sahi and click on configure link on the SahiDashboard. 13) Go to browser_types.xml and revert back the changes which you made in the <browserType> chrome tag. It means whatever you have removed from the <options> tag in chrome, revert it back. Add the --proxy-server=127.0.0.1:9999 in <options> tag.After making the changes the <option> tag will look something like below <options>--user-data-dir=$userDir\browser\chrome\profiles\sahi$threadNo --proxy-server=127.0.0.1:9999 --always-authorize-plugins --allow-outdated-plugins --enable-npapi --incognito</options> 14) Save the file and restart Sahi. You may see a strange error like this:
Wrapped java.util.zip.ZipException: invalid entry size (expected 3489623983 but got 1624 bytes) (RhinoScriptRunner.run#2386) The above means that the spreadsheet is corrupt. Just replace it. If your database shows SAHI_ERROR or you think Sahi is slowing down, check the file size of your "logs" folder, which is found in your "userdata" folder (the same parent folder as your "scripts" folder).
Just rename your "logs" folder to "logs.old" or remove the old logs folder. Sahi will create a new, fresh logs folder upon restarting, and this can hasten your Sahi performance, as needed. It will also be necessary to rename the "database" folder or to remove it from time to time. It can grow in sizes of multiple gigabytes. This might prevent the "SAHI_ERROR" message in your database logs. Using _condition or otherwise accessing the DOM increases the risk of Sahi crashing with the "150 second" timeout error. I am using Sahi 6.1, so perhaps a future release will reduce this risk. FYI.
Sahi requires 2 main differences in its javascript coding:
1. All variables must start with a $ sign. For example: var $value = "1234"; 2. Use a special _set() function to access values in the browser DOM. For example: _set($value, window.top.location.href); //get the browser url If you are using a function to returns a value to _set, add <browser> tags around that function. For example: _set($response, get_metatag_content("http-equiv","Content-Language")); //access DOM to get a specific Metata tag <browser> function get_metatag_content($withAttributeName,$withAttributeValue) { var $elements = document.getElementsByTagName("meta"); for (var $i = 0; $i < $elements.length; $i++) { if ($elements[$i].getAttribute($withAttributeName) == $withAttributeValue) { var $content = $elements[$i].content; return $content; } }return "not found"; } </browser> It turns out that if you enclose your code with <browser> tags, it is using the javascript engine of the browser, not the Rhino javascript engine that powers Sahi. Therefore, you actually don't need the $ symbol in that case (but the example above uses them anyways.) SahiOS (free) vs. SeleniumSahiOS was designed for non-SSL sites. It works over HTTP, but requires special setup to work over SSL. The locator spy doesn't work in HTTPS, so Selenium is the winner for any site using HTTPS. SahiOS has limited functionality compared to Sahi Pro, for example, it doesn't have the ability to take screenshots, which also puts Selenium at an advantage. Here is the SahiOS function list. With that in mind, SahiOS is still recommended for --any pop-up handling, as selenium has a hard time handling pop-ups predictably. --any javascript/ajax functions that cause implicit wait issues, where selenium sometimes works and sometimes doesn't. --less maintenance, where the locator code should not need change while the rest of the page is going to be changing. The xpath (the selenium locator if you don't have an element id) will change with a header change. If you don't want to fix your test code every time other content on the page changes, SahiOS can still locate HTML elements without an element ID using code like _link("text"). Of course, if your element has an id, both Selenium and Sahi can use that to locate the element reliably. Selenium IDE is superior over SahiOS for a) increased functionality including screenshots, b) element locator spy works over httpS, and c) world-wide support. SahiOS is still useful for minor code edits without having to make another purchase. Sahi Pro vs SeleniumThe incredible value of Sahi Pro is the use of locators such as this:
_link(0, _near(_image("icon"))) With that alone, you don't need to worry about id properties to locate elements, and you don't need to worry about maintenance simply because other content on the page has changed. It allows you to rotate through may localized versions of the same page using one locator (ease of maintenance) For example: https://www.apple.com/uk/shop/buy-iphone/special-edition-iphone-7 https://www.apple.com/mx/shop/buy-iphone/special-edition-iphone-7 That alone makes Sahi Pro worth the (current price) of $700, plus the fm-report test template makes it easy to report. Sahi Pro is also a bit more predictable when testing, so I consider it more reliable in its results. If I have to send a daily email report to management about some website test, I want to use Sahi's reliability to prevent false alarms. It's ease of use for using additional functionality like _assertEqualImages makes Sahi Pro an easy winner over Selenium. It sometimes can use locators from jQuery (they cannot be stored in a variable) and it offers the easy-to-use language of javascript for incredible access to the DOM and to functions like computedStyle (actual, visible css styling). I recommend Sahi Pro to anyone who needs easier functionality and can afford a one-time fee of $700 (includes one year of support). Sahi Pro is the winner over selenium for ease of use, increased functionality, and lower need of maintenance. It is more reliable in its test results than Selenium IDE. Selenium 3.4 is faster, and I believe that webdriver has fewer crashes. More info: http://sahipro.com/sahi-open-source/ http://www.seleniumhq.org/
Be sure to add this flag in the browser_types.xml settings, found in the "configure" link in the SahiOS dashboard:
--ingore-certificate-errors If you don't see Chrome offered, you may need to alter the "path", too. In the example below, I had the change the path from $ProgramFiles (x86) to be just $ProgramFiles. <browserType> <name>chrome</name> <displayName>Chrome</displayName> <icon>chrome.png</icon> <path>$ProgramFiles\Google\Chrome\Application\chrome.exe</path> <options>--incognito --user-data-dir=$userDir\browser\chrome\profiles\sahi$threadNo --proxy-server=localhost:9999 --disable-popup-blocking --ignore-certificate-errors</options> <processName>chrome.exe</processName> <capacity>5</capacity> </browserType> With a free personal email account from Zoho, it is possible to use fmReports in the free version of Sahi, SahiOS. Additionally, here is a free linux VM with SahiOS (and other open-source software). Assuming you are using the above VM: 1. Log in with "tests" and "tests" 2. Double click "Sahi" on the desktop 3. Click the Firefox button. 4. Click the link for "Sahi Controller" 5. SahiOS is broken, and it will open 2 controllers. Close the 2nd one. (Sahi Pro doesn't have this issue.) 6. Click the 2nd tab for "Playback". It should look like this: 7. For the File enter testSample/launch.sah
8. For the Start URL it is recommended to enter "http://mail.zoho.com" so that before every script the mail SSL is automatically accepted. (SahiOS is blocked by https/SSL, but Sahi Pro is not.) 9. Click "Set". 10. Before clicking Play: Get an email account from Zoho and enter it and the password in fmReports.sah, which is in the "includes" folder of testSample. Click on "Komodo Edit" on the desktop, and it should go right to "fmReports.sah". 11. After clicking "save", you should click the "Play" button. If you are using your own system: To set it up, first open a firefox browser and use "File", then "Open" to manually open the .xpi file for the plugin "Skip Cert Error". SahiOS is blocked by https/SSL by default. Please comment or use the contact form for additional features/comments.
|