浏览器配置文件和用户代理在 UI 测试中有何意义?
我在 selenium 2 的文档中看到一个名为“调整现有的 Firefox 配置文件”的部分,想知道在 UI 测试期间更改配置文件和用户代理的原因是什么?另外,自定义配置文件何时何地有用?
谢谢
I see a section called "Tweaking an existing Firefox profile" in selenium 2's documentation and wondering what would be the reason to change profiles and user agents during UI testing? Also when and where are custom profiles helpful?
thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
自定义配置文件
有时您可能想要对具有伪造 SSL 证书的应用程序服务器运行功能测试。在这种情况下,Selenium 会让您头疼,因为您会收到弹出窗口来接受 Selenium 无法与之交互的证书。此外,Selenium 将为每个测试创建和销毁自定义的 Firefox 配置文件。即您每次都会弹出一个接受无法识别的证书的窗口,并且必须手动单击它。即使您选择“永久接受”,您也会继续收到弹出窗口,因为您的个人资料未保存。
您可以创建自己的自定义配置文件并使用此配置文件运行 Selenium 测试。如果这样做,您可以一次接受所有证书,Firefox 将永远不会提示您再次接受它们。
用户代理
根据 http 请求的来源,某些网站的行为会有所不同。例如,装有 Safari 的 iPhone 和装有 IE 的 PC 可以访问相同的 URL,并获得外观截然不同的网页。这是由用户代理控制的。如果您需要测试 iphone safari 页面,您可以将用户代理更改为“Mobile Safari 2.2.1 – iPhone”之类的内容
如果您的服务器向所有浏览器和设备提供相同的内容,那么您可能不必担心。
http://garbuz.com/2010/07/ 31/running-selenium-with-custom-firefox-profile/
custom profiles
Sometimes you may want to run functional tests against an application server that has fake SSL certificates. In that case Selenium will give you headache because you'll get popups to accept the certificates that selenium can't interact with. Also, Selenium will create and destroy a custom Firefox profile for each test. i.e. You will get a popup to accept an unrecognised certificate every time and it has to be manually clicked. Even if you select 'permanently accept' you'll continue to get the popup because your profile is not saved.
You can create your own custom profile and run your Selenium tests using this profile. If you do, you can accept all of the certificates once and Firefox will never prompt you to accept them again.
user agents
Some websites will behave differently depending on where the http requests are coming from. For example, an iphone with safari and a pc with IE could hit the same url and get very different looking web pages. This is controlled by the user agent. If you need to test that iphone safari page, you can change your user agent to something like "Mobile Safari 2.2.1 – iPhone"
If your server delivers the same content to all browsers and devices, then you probably don't have to worry about it.
http://garbuz.com/2010/07/31/running-selenium-with-custom-firefox-profile/
您还可以使用所需的证书密钥库状态创建自定义 Firefox 配置文件,以允许访问某些站点。
You can also create custom Firefox profiles with a desired certificate keystore state to allow access into certain sites.