2

I would like to use verifyElementPresent to skip a chunk of code in my Selenium test script. I used something like this successfully in the older Firefox extension, but I can't figure out how to make it work in the Chrome Kantu version.

I have tried both ${!statusOK}==true and ${!lastCommandOK}==true and I have found them to both be finicky. I can't get a consistent test case with either one and I'm not sure why. I used storeElementPresent in the FireFox browser extension and it worked consistently, but that command isn't available in Kantu.

The below link outlines the EXACT scenario I'm trying to use verifyElementPresent for, but it isn't working for me. Does anyone know of another way to do this?

https://a9t9.com/kantu/docs/selenium-ide/assertelementpresent-verifyelementpresent

{
   "Command": "verifyElementPresent",
   "Target": "//table[@id='phHeader']/tbody/tr/td[3]/div/div/div/span[2]",
   "Value": ""
},
{
   "Command": "gotoIf",
   "Target": "${!statusOK} == true",
   "Value": "logOut"
},
{
   "Command": "gotoIf",
   "Target": "${!statusOK} == false",
   "Value": "logIn"
},

I expect that when the element is present, it will go to the "logOut" label of the code.

Please see image of my Kantu player to see exactly where it malfunctions: https://i.stack.imgur.com/21HG0.jpg

Thank you!

Amanda.in.ATX
  • 21
  • 1
  • 4

2 Answers2

2

I wanted to do the same thing as the described problem. I found a solution for Selenium IDE, but it doesn't use the verify element present command. As there is no other solution to this problem I will post a way i found to help.

Instead of verify element present command, you should use the following: Command: store xpath count Target: <locator of object to find>, example: xpath=\\a[id='logout'] Value: number

So the whole code for checking if a element is present looks like:

Command: store xpath count
Target: <locator of object to find>
Value: number
Command: if, Target: ${number} == 1
Command: click, Target: <locator> 

... Any commands you want to execute

Command: end
Rest of code outside of if

Where <locator> can be xpath, css selector. Example: xpath=\\a[id='logout'] Tested on latest version 3.17.0 on Firefox Selenium IDE.

Warkaz
  • 845
  • 6
  • 18
0

The only solution I can find is to manually set !statusOK to true before each verify statement. It looks like it was getting stuck on a previous fail. This would explain why it seemed to behave so differently each run. I hope my struggle and eventual explanation is helpful to someone else! I'm still looking for tips on how to get these scripts to work better, so let me know if you have any good tricks!

https://a9t9.com/kantu/docs#!statusOK

!statusOK (read/write) - contains the status of the macro execution. Once an error happens !statusOK is set to FALSE. Use with !ErrorIgnore set to true so the macro execution continues after an error. Only then !statusOK will be useful. Otherwise the macro stops at an error anyway. !statusOK is similar to !LastCommandOK but it does not get reset by a successful command. Once !statusOK is set to "false" by an error, it remains "false", even if the next commands succeed. But you can use store | true | !StatusOK to manually reset it.

Amanda.in.ATX
  • 21
  • 1
  • 4