- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 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">
虽然 Firefox 返回了这个。
"<!DOCTYPE html>
<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" />
有没有办法让 IEDriver 以与 FirefoxDriver 相同的方式返回 pageSource?
最佳答案
不,那是因为 getPageSource
方法不像在浏览器中手动那样返回页面源,而是返回 DOM 的文本表示。 Javadoc of getPageSource
更好地解释它:
java.lang.String getPageSource()
Get the source of the last loaded page. If the page has been modified after loading (for example, by Javascript) there is no guarantee that the returned text is that of the modified page. Please consult the documentation of the particular driver being used to determine whether the returned text reflects the current state of the page or the text last sent by the web server. The page source returned is a representation of the underlying DOM: do not expect it to be formatted or escaped in the same way as the response sent from the web server. Think of it as an artist's impression.
关于selenium - InternetExplorerDriver getPageSource() 返回的字符串与 FirefoxDriver 不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17734065/
这个问题已经有答案了: What does it mean to "program to an interface"? (33 个回答) Is this correct - FirefoxDriver
我看到几乎每个人都使用语句 WebDriver driver=new FirefoxDriver(); 这里我们创建了一个 FirefoxDriver 类的实例,其类型为 Webdriver;如果我直
上周有很多关于这个名为 Marionette 的新 FirefoxDriver 的噪音。为了将 Firefox 与 Selenium 一起使用,我们曾经使用“旧的”Selenium FirefoxDr
我制作了一个 Java 应用程序,它将从我们的暂存环境中获取的屏幕截图与生产环境中的屏幕截图进行比较。由于屏幕截图尺寸不同,应用程序失败。 如何定义屏幕截图尺寸?我使用以下代码来生成屏幕截图。
有人解决了吗? 每当我有提交按钮时,我都必须进入解决方法并向其发送“Enter”键。更具体地说: WebDriver driver = new FirefoxDriver(); driver.ge
一段时间以来,我们一直在使用 FirefoxDriver 执行一组基于 WebDriver 2.25.0 的自动化测试。测试由基于 Maven 3.0 的构建及其 FailSafe 插件并行执行(在四
我在 stackoverflow 上发现了一个与我类似的错误,并使用以下方法将 selenium webdriver jar 文件添加到项目中: 右键单击项目--> 转到构建路径--> 配置构建路径-
当我运行以下代码时,我不断收到 unsupportedCommandException: System.setProperty("webdriver.firefox.bin","C:\\Program
我期望浏览器显示代理值,但它显示了我的实际 IP。知道为什么吗? ''' FirefoxOptions options = new FirefoxOptions(); options.addPrefe
public class Tester implements Runnable { public Tester() { // Init WebDriver Fi
尝试在 weebly 中自动创建一个网站,一切正常,直到我进入主题选择页面。您需要将鼠标悬停在图片上,以便选择按钮可见。到目前为止我的代码。 WebDriver driver = new F
我试图告诉Selenium的org.openqa.selenium.firefox.FirefoxDriver使用现有的配置文件及其cookies和代理设置,所以我我正在做: FirefoxProfi
我正在尝试检索 JavaScript 全局变量的值,但在 FireFox 中运行测试时总是得到 undefined。 此测试在 Chrome 中成功。 index.html window.
我第一次尝试使用 Selenium 来驱动 Firefox。我使用几乎相同的代码来驱动 Chrome,没有问题。但是,当我尝试使用 Firefox 驱动程序时,浏览器打开、停止,然后在大约 60 秒后
我有以下代码来测试 Selenium WebDriver。 import org.openqa.selenium.WebDriver; import org.openqa.selenium.firef
我正在使用 Selenium 2.35 并在尝试单击 firefox 中的元素时出现不可预知的错误,如下所示: new Actions(driver).moveToElement(element).c
我将 Selenium 与 FirefoxDriver 一起使用,当它实例化时,FireFox 浏览器自动打开,我们如何隐藏它? WebDriver 驱动程序 = new FirefoxDriver(
我正在使用 python 3.5 编写示例 selenium 代码以打开链接 https://www.python.org/当我执行 py 时它显示以下错误..但是 FirefoxDriver.exe
我正在 gwt 上测试繁重的 Web 应用程序。测试在每次启动时创建新的 webdriver 实例,打开浏览器并加载页面。 一段时间后,测试通过。测试后我没有关闭浏览器,但是当我重新运行测试时,它会再
我尝试开始使用 selenium(今天下载了当前版本)并复制了他们打开浏览器并执行 google 搜索的示例。 但是,程序在第一行永远挂起WebDriver driver = new FirefoxD
我是一名优秀的程序员,十分优秀!