How to Troubleshoot Selenium ScriptsOne of the advantages of using Compliance Sheriff is the ability to leverage transaction scripts. This allows Compliance Sheriff to scan content that involves user interaction such as logging in through a portal, filling out a web form application, or even the process of purchasing a product online. This is one of the main reasons that Compliance Sheriff is used to scan against just about any web content one can imagine. When used correctly, a transaction script can be used for many different types of target content, but in order to get a script to work correctly for your specific project, there is a specific "trial and error" process involved, and this article will walk you through that process.
- Install Selenium along with the "ComplianceSheriff Add-ON" toolbar. You can find links to the download pages from within Compliance Sheriff, on each scan page next to the "Transaction Script" section, where it says "see instructions": Once you have Selenium installed your client, you'll need to create your first script. Generally we recommend something basic, with only a few lines for the intial testing. If you haven't run Selenium yet in your environment, you may want to read this kb article first:https://cryptzone.force.com/support/articles/Customer/Example-of-Selenium-Script-for-Login-Page/?l=en_US
:2. The script that you have copied into your scan configuration page should look similar to this:
3. Save and then run your scan. Once the scan has completed, the first thing to do is check the Scanlog by clicking the word "completed" under the status column:
4. While viewing the scan log, look for any red "x"'s , such as the following:
5. In the above example I was attempting to scan through the login process of my gmail account. This scan log is telling me that the scan engine "couldn't find control id = Email". This means that the script failed at this exact point, and could therefore not go any farther. I need to go back to my Selenium script and try a different command, like so:
TIP -- Look closely at your Selenium IDE window, and locate the area below with the three sections "Command", Target" , and "Value". See the drop down arrows next to the "target" and "command" fields"? Selenium will give you several options for each, and I'll be changing the "target" value in my next step.
6. First I locate the line of code where it has my "ID=Email" target. Then I'll click the little drop down arrow next to the "target" section below, to find a different target variable.
Once I have a new target variable, I'll recopy my script, run another scan, and check the scan log again. This is basically what this "Trial and Error" script recording process is all about.
- Record a script and play it back in selenium to make sure it works
- Use the Compliance Sheriff Add-On "clipboard" top copy the script
- Run the scan
- Check the "Status" log by clicking the word "Completed"
- Look for any red "x"'s -- these will be the stopping point of the scan
- Change the element that failed by adjusting the "target" value within Selenium
- Run the scan again