This is a migrated thread and some comments may be shown as answers.

Nested tables and invalid markup

3 Answers 234 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Przemek
Top achievements
Rank 1
Przemek asked on 20 Mar 2020, 04:22 PM

Hi,

we have a system we want to test with Testing Framework. Of course it is a legacy system that has not very well formatted HTML markup and of course is too expensive to change - you probably all know this...

On this page we have a problem with one of the rows in the nested table does not have an enclosing end tag. This results in table not being found. But only, if the table is searched from a form on the page. If tables are searched from the root of the page, invalid table is found.

Why is that? I would expect to find all tables inside the form, regardless of whether I am searching within the form or the whole tree?

I have attached a VS project which reproduces the problem.

3 Answers, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 24 Mar 2020, 03:47 PM

Hi Przemek,

Thank you for preparing a sample project to demonstrate the issue you have encountered. 

As far as I can see you are not using the page under test in a browser, but you take a string object parsed from the html of the page. Can you, please, elaborate more on that part of the test?

Next thing I checked on my end was the sample page you shared and if I am able to locate the nested tables using the Testing Framework identification methods. Please, note that the usage of these methods is under the current ActiveBrowser object. 

So, using the below sample code, I am able to locate all of the tables on the page hosted under my local IIS.

Manager.ActiveBrowser.NavigateTo("http://localhost/objectdetails.html"); 
            
            var tables = Manager.ActiveBrowser.Find.AllByTagName("table");
            this.Log.WriteLine(tables.Count.ToString());
            
            HtmlForm form = Manager.ActiveBrowser.Find.ById<HtmlForm>("nestedForm");
            Assert.IsNotNull(form);
            
            var nestedFormtables = form.Find.AllByTagName("table");
            this.Log.WriteLine(nestedFormtables.Count.ToString());
            
            HtmlTable notFound = form.Find.ById<HtmlTable>("notFoundTable");
            Assert.IsNotNull(notFound);

As a conclusion, it will be helpful for me to find out more about the approach you have chosen to test something in the application under test and if there is a reason to not use the activeBrowser object from the Testing Framework. 

In case you have any further queries, please, do not hesitate to get back to me.

Regards,
Elena
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Przemek
Top achievements
Rank 1
answered on 26 Mar 2020, 03:20 PM

Hi Elena,

thank you for the analysis.

Unfrotunately in our legacy project that we have to support, part of the logic is done with Testing Framework by opening a browser and parsing the data there. But some of the work is done with usage of curl.exe when there is one request for one specific page and also Testing Framework is used to parse returned data.

Resulted HTML is not properly formatted, which result in such behavior.

1. I was just curious why in such case, searching from the root behaves differently than searching in context of nestedForm?

2. I was able to overcome this problem by using Html Agility Pack library to correct html as much as possible, so Testing Framework can do its job.

3. It probably works for you in the browser, because the browser adds missing tags or interprets not properly formatted attributes.

4. I could use browser to do those single request, but I would have to disable JavaScript execution, because otherwise some JavaScript logic redirects me to another page after such request. Is it possible to disable JavaScript execution from Testing Framework level?

 

Regards,

Przemek

0
Elena
Telerik team
answered on 31 Mar 2020, 12:38 PM

Hello Przemek,

Thank you for the additional details - these are really helpful for me to better understand the requirements of the task you need to accomplish. 

So, as you have initially identified the parsed data from the not properly formatted html is not complete and the structure of the html gets messed up. You are also correct that the browser fixes this and thus using the same html in the browser is not an issue. 

The issue with searching the table element from the root and from the nestedForm is related to that not correctly formatted html. Due to the missing row enclosing end tag, the structure of the complete html in the parsed file is different and thus the table is no longer nested under the mentioned form. This is what causes the difference in the search results at the end. 

Apart from this, I am pleased to know you have managed to find a workaround for this case and it works fine for you. I hope that there are no other issues with these legacy apps you are testing. Of course, in case of any questions, please, let me know. 

Thank you for your continuous cooperation.

Regards,
Elena
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
General Discussions
Asked by
Przemek
Top achievements
Rank 1
Answers by
Elena
Telerik team
Przemek
Top achievements
Rank 1
Share this question
or