Need to compare 2 html documents using Java & selenium

后端 未结 1 448
忘掉有多难
忘掉有多难 2021-01-07 06:17

I have to check the differences between two html pages: One is an old version and the other is the updated page.

I need Selenium to get the source of the two pages a

1条回答
  •  别那么骄傲
    2021-01-07 06:31

    Use selenium.getHtmlSource() for each page and either compare the returned Strings in Java or save them to files and use a command line tool such as "diff".

    If using Java, two methods I can think of are using something like StringUtils.difference() (almost certainly a mess) or better yet Google Diff. Google diff has a Java library and test example.

    Of course the outputs of these will be a literal diff, you might want something more custom to make sense of changes in HTML.

    0 讨论(0)
提交回复
热议问题