canopy
canopy copied to clipboard
Not able to read a value of the locator
Hi Team,
I am trying to read a value for particular locator and comparing with expected value but my canopy code is reading blank value for that locator.
let locator = ".//h2[@ng-if="vm.property.PropertyId"]"
let expectedValue = "Property Essentials"
displayed locator
let actualValue = read Locator
expectedValue === actualValue
I tried many locators which are highlighted using xpath checker add-in also if I write a code to verify element is displayed or not then it works fine.
Attaching screen shot for error and locator identification.
Could you please help?
Without seeing the html I can only guess. I bet that inside the h2 there is a div or span or some other element that actually contains the value of Property Essentials
Hi,
There is no div or span present under h2. Attaching HTML code.
Facing similar issue with few other locators on same screen. Basically not able to read value of the locators present inside this form.
Hmm, next guess would be that you are using ===
instead of ==
, the triple = does not do any retries, its like a normal unit test assertion for equality.
==
will try again and again until its true or a time limit is hit and it fails. It could be that at the point you are trying to do the assertion, the page is not finished loading and that H2 is not there.
Switching to ".panel-title" == "Property Essentials"
will probably fix it.
I dont find myself using read
or ===
very often personally.