canopy icon indicating copy to clipboard operation
canopy copied to clipboard

Not able to read a value of the locator

Open RutujaNagare opened this issue 3 years ago • 3 comments

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?

Locator_ByXpathChecker Error_AtResult

RutujaNagare avatar Jun 24 '21 12:06 RutujaNagare

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

lefthandedgoat avatar Jun 24 '21 15:06 lefthandedgoat

Hi,

There is no div or span present under h2. Attaching HTML code. HTMLCode

Facing similar issue with few other locators on same screen. Basically not able to read value of the locators present inside this form.

RutujaNagare avatar Jun 25 '21 06:06 RutujaNagare

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.

lefthandedgoat avatar Jun 25 '21 14:06 lefthandedgoat