use*_*456 2 selenium webdriver
我是Selenium的新手,想知道是否有人可以指出我正确的方向.
我试图获取页面的页面源,但我注意到IE驱动程序返回的内容与FirefoxDriver不同.
此外,InternetExplorerDriver.getPageSource()返回的字符串与我在IE上单击视图页面源时看到的字符串不同.
我正在运行IE 8和Firefox 22.
有关此页面上的示例: http://stackoverflow.com/questions/16455217/webdriver-save-the-location-of-the-id-in-the-page
当我调用getPageSource()时,IE返回了这样的东西.
"<HTML><HEAD><TITLE>selenium - Webdriver / Save the location of the ID in the page - Stack Overflow</TITLE><LINK rel="shortcut icon" href="https://cdn.sstatic.net/stackoverflow/img/favicon.ico"><LINK rel="apple-touch-icon image_src" href="https://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png">
Run Code Online (Sandbox Code Playgroud)
虽然Firefox归还了这个.
"<!DOCTYPE html>
Run Code Online (Sandbox Code Playgroud)
<title>selenium - Webdriver / Save the location of the ID in the page - Stack Overflow</title>
<link href="https://cdn.sstatic.net/stackoverflow/img/favicon.ico" rel="shortcut icon" />
<link href="https://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png" rel="apple-touch-icon image_src" />
Run Code Online (Sandbox Code Playgroud)
IEDriver是否有办法以与FirefoxDriver相同的方式返回pageSource?
不,那是因为该getPageSource方法不会像在浏览器中手动返回页面源那样返回页面源,而是返回DOM的文本表示.JavadocgetPageSource解释得更好:
java.lang.String getPageSource()获取上次加载页面的来源.如果页面在加载后已被修改(例如,通过Javascript),则无法保证返回的文本是已修改页面的文本.请参阅用于确定返回文本是否反映页面当前状态或Web服务器上次发送的文本的特定驱动程序的文档.返回的页面源是底层DOM的表示:不要期望它以与从Web服务器发送的响应相同的方式进行格式化或转义.把它想象成艺术家的印象.
| 归档时间: |
|
| 查看次数: |
1075 次 |
| 最近记录: |