lefthandedgoat / canopy

f# web automation and testing library, built on top of Selenium (friendly to c# also)
http://lefthandedgoat.github.io/canopy/
MIT License
505 stars 117 forks source link

Not able to read a value of the locator #521

Open RutujaNagare opened 3 years ago

RutujaNagare commented 3 years ago

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

lefthandedgoat commented 3 years ago

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

RutujaNagare commented 3 years ago

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.

lefthandedgoat commented 3 years ago

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.