页面不存在!
您访问的页面无法找到
3 秒后将自动跳转到导航页
请检查您输入的地址是否正确 |
|
|
English Title:The GetText of Selenium also can take sightless content in Ie
最近在使用selenium做自动测试,发现对于不可见内容,在firefox和ie中的表现不一样,firefox只返回可见的内容,而ie却将不可见内容也一起返回,大家有用到的时候要注意。下面是一个小例子:测试用的页面如下:其中"show"文字是可见的,"hide"文字是不可见的。 <html> <head> <title>testV</title> </head> <body> <div id="all"> <div id="visible">show</div> <div id="invisible" style="display:none">hide</div> </div> </body> </html> 测试代码如下,其中参数是使用的浏览器,用firefox测输入"firefox",用ie测输入"iexplore" import org.openqa.selenium.server.SeleniumServer; import com.thoughtworks.selenium.DefaultSelenium; public class Test { public static void main(String[] args) throws Exception { DefaultSelenium selenium = new DefaultSelenium("localhost", 4444, args[0], "http://192.168.20.128"); SeleniumServer server = new SeleniumServer(); server.start(); selenium.start(); selenium.open("test.html"); selenium.getText("all"); selenium.isElementPresent("visible"); selenium.isElementPresent("invisible"); selenium.isVisible("visible"); selenium.isVisible("invisible"); selenium.stop(); server.stop(); } } 用firefox测的结果如下:注意selenium.getText("all")得到的是"show",isElementPresent都返回true,"visible"的isVisible返回true,"invisible"的isVisible返回false12:05:45.373 INFO - Command request: open[test.html, ] on session d79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.454 INFO - Got result: OK on session d79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.456 INFO - Command request: getText[all, ] on session d79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.468 INFO - Got result: OK,show on session d79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.470 INFO - Command request: isElementPresent[visible, ] on session d79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.482 INFO - Got result: OK,true on session d79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.484 INFO - Command request: isElementPresent[invisible, ] on session d79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.498 INFO - Got result: OK,true on session d79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.500 INFO - Command request: isVisible[visible, ] on session d79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.514 INFO - Got result: OK,true on session d79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.517 INFO - Command request: isVisible[invisible, ] on session d79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.532 INFO - Got result: OK,false on session d79b5f22b4cd4025bfbe00ac6df14e3c用ie测的结果如下:注意selenium.getText("all")得到的是"show hide",其他和firefox一样。11:58:00.576 INFO - Command request: open[test.html, ] on session 80a09c3dfde642eba6b91615320ee2e111:58:01.357 INFO - Got result: OK on session 80a09c3dfde642eba6b91615320ee2e111:58:01.357 INFO - Command request: getText[all, ] on session 80a09c3dfde642eba6b91615320ee2e111:58:01.466 INFO - Got result: OK,showhide on session 80a09c3dfde642eba6b91615320ee2e111:58:01.466 INFO - Command request: isElementPresent[visible, ] on session 80a09c3dfde642eba6b91615320ee2e111:58:01.576 INFO - Got result: OK,true on session 80a09c3dfde642eba6b91615320ee2e111:58:01.591 INFO - Command request: isElementPresent[invisible, ] on session 80a09c3dfde642eba6b91615320ee2e111:58:01.701 INFO - Got result: OK,true on session 80a09c3dfde642eba6b91615320ee2e111:58:01.701 INFO - Command request: isVisible[visible, ] on session 80a09c3dfde642eba6b91615320ee2e111:58:02.232 INFO - Got result: OK,true on session 80a09c3dfde642eba6b91615320ee2e111:58:02.232 INFO - Command request: isVisible[invisible, ] on session 80a09c3dfde642eba6b91615320ee2e111:58:02.607 INFO - Got result: OK,false on session 80a09c3dfde642eba6b91615320ee2e1
==========English==========
Automatic test is done in use Selenium recently, discover to sightless content, the expression in Firefox and Ie is different, firefox returns visible content only, and Ie also returns sightless content together however, everybody is useful to when want to notice. A trivial example is below: The page that measures try out is as follows: Among them "show" character is visible, "Hide" character is sightless. <html><head><title>testV</title></head><body><div Id="all "><div Id="visible">show</div><div Id="invisible" Style="display:nOne">hide</div></div></body></html>Test code is as follows, among them parameter is use browser, measure input "firefox" with Firefox, measure input "iexplore" import Org.openqa.selenium.server.SeleniumServer; import Com.thoughtworks.selenium.DefaultSelenium; public Class Test {public Static Void Main(String[] Args) Throws Exception {DefaultSelenium Selenium = New DefaultSelenium("localhost" with Ie, 4444, args[0] , "Http://192.168.20.128"); SeleniumServer server = new SeleniumServer(); server.start(); selenium.start(); selenium.open("test.html"); selenium.getText("all"); selenium.isElementPresent("visible"); selenium.isElementPresent("invisible"); selenium.isVisible("visible"); selenium.isVisible("invisible"); selenium.stop(); server.stop(); } } Yong firefox Ce De Jie Guo Ru Xia : Noticing what Selenium.getText("all") gets is "show" , isElementPresent returns True, "The IsVisible of Visible" returns True, "The IsVisible of Invisible" returns False12:05:45.373 INFO - Command Request: Open[test.html, ] On Session D79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.454 INFO - Got Result: OK On Session D79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.456 INFO - Command Request: GetText[all, ] On Session D79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.468 INFO - Got Result: OK, show On Session D79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.470 INFO - Command Request: IsElementPresent[visible, ] On Session D79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.482 INFO - Got Result: OK, true On Session D79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.484 INFO - Command Request: IsElementPresent[invisible, ] On Session D79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.498 INFO - Got Result: OK, true On Session D79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.500 INFO - Command Request: IsVisible[visible, ] On Session D79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.514 INFO - Got Result: OK, true On Session D79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.517 INFO - Command Request: IsVisible[invisible, ] On Session D79b5f22b4cd4025bfbe00ac6df14e3c12:05:45.532 INFO - Got Result: OK, the outcome that False On Session D79b5f22b4cd4025bfbe00ac6df14e3c measures with Ie is as follows: Noticing what Selenium.getText("all") gets is "show Hide" , other with Firefox. 11:58:00.576 INFO - Command Request: Open[test.html, ] On Session 80a09c3dfde642eba6b91615320ee2e111:58:01.357 INFO - Got Result: OK On Session 80a09c3dfde642eba6b91615320ee2e111:58:01.357 INFO - Command Request: GetText[all, ] On Session 80a09c3dfde642eba6b91615320ee2e111:58:01.466 INFO - Got Result: OK, showhide On Session 80a09c3dfde642eba6b91615320ee2e111:58:01.466 INFO - Command Request: IsElementPresent[visible, ] On Session 80a09c3dfde642eba6b91615320ee2e111:58:01.576 INFO - Got Result: OK, true On Session 80a09c3dfde642eba6b91615320ee2e111:58:01.591 INFO - Command Request: IsElementPresent[invisible, ] On Session 80a09c3dfde642eba6b91615320ee2e111:58:01.701 INFO - Got Result: OK, true On Session 80a09c3dfde642eba6b91615320ee2e111:58:01.701 INFO - Command Request: IsVisible[visible, ] On Session 80a09c3dfde642eba6b91615320ee2e111:58:02.232 INFO - Got Result: OK, true On Session 80a09c3dfde642eba6b91615320ee2e111:58:02.232 INFO - Command Request: IsVisible[invisible, ] On Session 80a09c3dfde642eba6b91615320ee2e111:58:02.607 INFO - Got Result: OK, false On Session 80a09c3dfde642eba6b91615320ee2e1
==========回复|reply==========
==========English==========