c# - How to compare the updated webpage with the non-updated one automatically? -
Sorry for my bad english
Let me update the details of the webpage as non-most, such as the location and size of all the elements.
I use Google diff for the first time. If the html source is the same, then I'll use the Selenium WebDrive to compare the elements.
P> Here is the code.
IWebDriver d1 = New FirefoxDriver (); IWebDriver d2 = new firefox driver (); . D1.Navigate () GoToUrl (URL); . D2.Navigate () GoToUrl (URL); Comparison (); . D1.Navigate () GoToUrl (url2); . D2.Navigate () GoToUrl (url2); Comparison (); Compare Public Zero () {List & lt; IWebElement & gt; List1 = New list & lt; IWebElement & gt; (); Foreign currency (iWebElement e in d1.FindElements (by CCSE ("*"))) {list1.Add (e); } Foreach (iWebElement in d2.FindElements (By.CssSelector ("*"))) {list2.Add (e); } For (int i = 0; i & lt; list1.Count; i ++) {if (list1 [i] .ize.ToString ()! = List2 [i] .ize.ToString ()) {// Not equal size} if (list 1 [space] .tostring ()! = List2 [ii] place.To string ()) {// not equal place}}}
< P> But it worked, if it had read too many pages, it could compare unmatched elements such as comparison of A element in page 1 with B element in page 1. The That's why I try to get XPath list of all elements with the HTML element to use Acpielagiliteepak, and then call the selenium to find elements by Xpath.
It worked fortunately, but this is a problem.
When Java code that will insert some HTML tags on web pages, and selenium will execute them, Actimelagiliteepak get the wrong XPath. For example, Html is
& lt; Div & gt; & Lt; / Div & gt;
then exposed is // div
.
But after executing JS, html
& lt; Div & gt; & Lt; Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;
is xpath // div / div
.
But the HTMLEgiftPack still receives // div
because it reads the Html source.
How can I solve it?
To read thx.
Comments
Post a Comment