atata-framework / atata

C#/.NET test automation framework for web
https://atata.io
Apache License 2.0
490 stars 80 forks source link

ControlList.Count.Value is return incorrect number of elements found #841

Closed daiphamn closed 3 months ago

daiphamn commented 3 months ago

We have found the first column list in a table by the Xpath below.

[FindByXPath("//*[@class='tbody']//*[@role='row']/div[1]")]
public ControlList<Text<_>, _> Names { get; private set; }

When I called Names.Count.Value, I expected it to be 20, but instead I received 500. Each of these contains all the webpage (HTML) text.

YevgeniyShunevych commented 3 months ago

[Find*] attributes don't work with ControlList, they work with ItemsControl defining the container control. To specify an XPath for ControlList item, you need to use [ControlDefinition] attribute like below:

[ControlDefinition("*[@class='tbody']//*[@role='row']/div[1]")]
public ControlList<Text<_>, _> Names { get; private set; }

Please note that preceding // should not be added to XPath.

daiphamn commented 3 months ago

Thank you. Let me try

daiphamn commented 3 months ago

It worked! Thanks

YevgeniyShunevych commented 3 months ago

You are welcome.