Selenium Core FAQ

上一篇 / 下一篇  2009-06-15 16:39:04 / 个人分类:Selenium

Selenium Core FAQ

这些是收集起来的关于Selenium Core的常见问题列表。我们鼓励人们丰富这个列表并对列出的内容进行回馈:

  1. Selenium是用来做什么的?
    • 它用来对Web应用程序做功能或系统测试。这些测试有些时候也被称作接收测试/用户测试/集成测试。Selenium不止意味着单元测试
  2. 为什么我不能让Selenium Core在Google工作? - 我尝试写一个简单的脚本进行google搜索。我遇到了各种各样的问题。它在你那里可以工作么?这是我的测试:
    Test Type  
    openhttp://www.google.com/ 
    typeqtesting tools
    clicksubmitButton 
    • 简单的回答是因为所有浏览器的JavaScript引擎内建的跨站点脚本安全策略,你不能编辑其它域内的网页的内容。外部的页可以正确的在test runner窗口中看到,但是Selenium不能查询或者编辑它里面的内容。
      换句话说,你不能在"foo.com"运行selenium来测试和编辑"bar.com"上的值或着电击上面的按钮。所以,在当前的方式下,你不能给google写"脚本"因为你的脚本并没有放在google.com。如果Selenium和你在测试的应用程序在同一个域中,当然,你就不会遇到跨站点脚本安全问题造成的功能限制了。
      • 你可以在这里阅读到更多源于跨站点脚本的问题:开发文档
  3. 我如何在外域或者远程的服务器上运行我的测试脚本,绕过跨站脚本安全问题?
    • 这里有几种方法可以绕过跨站脚本安全(限制):
      • 如果可能,部署将Selenium Core和你的测试部署在你正在测试的应用程序里面。
      • 或者:使用Selenium IDE运行你的自动化测试。Selenium IDE是一个firefox扩展(插件),(它以"chrome" url方式运行)这样它不受浏览器的安全限制。
      • 或者:使用Selenium Remote Control运行你的测试。Selenium Remote Control提供一个配置在客户端的代理,来欺骗浏览器,使其认为应用程序和测试工具(脚本)来自同一个域。
      • 或者:让Selenium作为"HTA"应用程序运行,或者在Internet Explorer中作为"HTML Application"运行。HTA应用运行于与其它受信的客户端应用程序相同的安全上下文中,所以不会受到跨域脚本的安全限制。(你可以在这里得到更多消息:MSDN
      • 还有,请查看相关的问题:"为什么我不能给google.com写脚本"。
  4. 你如何创建测试表格?
    • The developers on the Selenium project use Mozilla Composer to create plain HTML text files for their
      tests. By default, Mozilla Composer writes very clean HTML without any extra, unnecessary markup.
      • You can also useSelenium IDEto write your tests scripts.
      • Another option is any text/html editor to create test tables. Future versions of Selenium may support RST (ReStructred Text), or wiki-table syntax, natively. However, you are free to use another format now, as long as you remember to generate the HTML files from your source files, either during your build process or dynamically at run-time.
  5. So I was able to deploy Selenium and my app showed up in the TestRunner, but my tests are failing with no errors, what gives?
    • One thing to check, especially if you are using Nvu, is that the third column in your test table (the optional arguments column) is not an empty cell. A single space or non-breaking space seems to be resolve the issue.
  6. I don't have access to the server where my AUT (application under test) is deployed, does that matter? IE., is physical deployment of app server and testrunner an issue?
    • Physical deployment doesn't strictly matter, but if you can't modify your AUT, you do have to somehow either force the browser to disable the same-origin policy or trick the browser into thinking that your tests and your AUT have the same origin.
  7. Selenium isn't working, where are the diagnostics for problem solving?
    • Look for JavaScript. errors. (In IE, check for a warning in your browser status bar; in other browsers you'll want to check the JavaScript. console for errors.) Additionally, try opening the logging window before you run your tests; that may reveal problems. You may also want to try using a JavaScript. debugger. In Internet Explorer you can configure theMS Script. Debugger; in Mozilla you can configureVenkman. (Be aware that there are several versions of Venkman; many of them are not forward/backward compatible with different versions of Mozilla/Firefox. Make sure you get the right one that works on your browser!)
  8. Selenium scripts are rather verbose - Is it possible to record these scripts to speed things up?
    • Yes, useSelenium IDEThis is a firefox plugin, so it requiresfirefox, but the results can be replayed using any browser you choose once the script. has been created.

你可以通过这个链接引用该篇文章:http://shmilyfan.bokee.com/viewdiary.17139033.html


TAG:

 

评分:0

我来说两句

Open Toolbar