I'm doing some Selenium tests now and I have code like this:
Assert.IsTrue(selenium.IsElementPresent("//div[text()='RSS Feed']"));
Assert.IsTrue(selenium.IsElementPresent("//div[@id='btnLogout_Container']"));
i've replaced it with this:
Assert.IsTrue(selenium.IsElementPresent("//div/dl/dt/a/div[text()='RSS Feed']"));
Assert.IsTrue(selenium.IsElementPresent("//tbody/tr/td/div[@id='btnLogout_Container']"));
Then I ran some testes and timed it - results were the same, difference was only in 0.001 second. So I wonder, does this changing (adding a more detailed way to XPath) a开发者_如何学编程ffects the speed of program and lowers time required to find an element on page?
It depends on the XPath processor and on many other things that you have told us nothing about. If your source document is small, for example, compiling the XPath expression will take much longer than executing it.
精彩评论