如何在不导出每个测试用例的情况下将Selenium IDE制作的测试用例转换为Python?那个工作有没有命令行转换器?
最后我想使用Selenium RC和Pythons构建单元测试来测试我的网站.
非常感谢.
更新:
我开始编写一个转换器,但实现所有命令的工作太多了.有没有更好的方法?
from xml.dom.minidom import parse
class SeleneseParser:
def __init__(self,selFile):
self.dom = parse(selFile)
def getTestName(self):
return self.dom.getElementsByTagName('title')[0].firstChild.data
def getBaseUrl(self):
return self.dom.getElementsByTagName('link')[0].getAttribute('href')
def getNodes(self):
cmds = []
nodes = self.dom.getElementsByTagName('tbody')[0].childNodes
for node in nodes:
if node.nodeType == node.TEXT_NODE and "\n" in node.data:
continue
if node.nodeType == node.COMMENT_NODE:
cmds.append(node.data)
if node.nodeType == node.ELEMENT_NODE:
cmd = []
for c in node.childNodes:
if c.nodeType == node.ELEMENT_NODE:
if len(c.childNodes) == 1:
cmd.append(c.childNodes[0].data)
else:
cmd.append("")
cmds.append(cmd)
return cmds
class PythonConverter:
def … 我有一组C#Selenium测试,需要删除一个设置了HttpOnly标志的cookie.
不幸的是,DefaultSelenium.GetCookie()和DefaultSelenium.DeleteCookie()命令无法访问cookie,因为它设置了HttpOnly标志.我已经通过手动删除标志来确认这一点,并检查对这些方法中的任何一个的后续调用是否能够愉快地操纵有问题的cookie.
有没有其他方法可以通过Selenium .NET客户端驱动程序执行此操作?
欢迎所有想法!
背景:我的目标是编写一个运行自包含的TestNG-Selenium系统(没有字符串到maven或ant插件;只是java).它必须允许测试用例接受包括浏览器和域URL的参数.当TestRunner实例化这些测试用例时,浏览器和域用于获取Selenium对象来执行它的测试.
问题:在尝试获取Selenium对象(在@BeforeTest中)之前,每个套件只有一个测试类成功获取域参数(在@BeforeSuite方法中).没有接收域的测试类具有空的selenium对象b/c它不能被实例化.
代码:XmlClasses每个都包含在他们自己的XmlTest中,并且所有三个都在一个XmlSuite中.该套件包含TestClass1,TestClass2和TestClass3的顺序.测试类本身是2层抽象基类的子类,包括初始化注入变量并随后获取Selenium实例的功能.这样做的目的是使用尽可能少的重复代码测试一个或多个应用程序(在多个域上)(即:Selenium实例化在根基类中,因为它对所有测试都是通用的).有关详细信息,请参阅以下方法
// Top-most custom base class
abstract public class WebAppTestBase extends SeleneseTestBase
{
private static Logger logger = Logger.getLogger(WebAppTestBase.class);
protected static Selenium selenium = null;
protected String domain = null;
protected String browser = null;
@BeforeTest(alwaysRun = true)
@Parameters({ "selenium.browser" })
public void setupTest(String browser)
{
this.browser = browser;
logger.debug(this.getClass().getName()
+ " acquiring Selenium instance ('" + this.browser + " : " + domain + "').");
selenium = new DefaultSelenium("localhost", 4444, browser, domain);
selenium.start();
}
}
// Second …Run Code Online (Sandbox Code Playgroud) 我阅读了有关用户扩展和扩展selenium但我想知道如何从我正在创建的自定义命令中调用命令.
我在Selenium IDE Options中向Selenium核心扩展(user-extensions.js)添加了类似于以下的文件.
// selenium-action-example.js
Selenium.prototype.doExample = function() {
this.doOpen("/"); // doesn't waitForPageToLoad like the command does
// These two commands are equivalent to the clickAndWait command. NOT!
// For proof, see the filterForRemoteControl function:
// http://code.google.com/p/selenium/source/browse/trunk/ide/src/extension/content/formats/formatCommandOnlyAdapter.js?r=8284#68
this.doClick("css=a#example");
this.doWaitForPageToLoad(); // doesn't wait at all
this.doClick("link=Example");
this.doWaitForElementPresent("example"); // error! undefined function
this.doClick("example");
};
Run Code Online (Sandbox Code Playgroud)
换句话说,我如何在自定义操作中的点击之间等待?
我们在Apache配置中有一堆重定向.我想用Selenium自动测试重定向,这导致了一些问题:
也许Selenium不是最好的解决方案.还有其他建议吗?
我是使用Selenium的新手.
Selenium IDE是一个用户友好的firefox插件.我没有使用它的问题.但是,我发现其他Selenium工具(如Selenium RC和Selenium Core)的文档对初学者来说非常混乱.似乎作者认为读者已经对使用这些工具有深入的了解.
例如,当我试图弄清楚如何设置Selenium RC来测试网络服务器时,我可以从Selenium网站找到的唯一图表是:
http://www.sparksupport.com/blog/wp-content/uploads/2010/11/selenium-rc.png
从这个图中,我甚至看不出哪个是被测试的网络服务器,我应该在哪里安装Selenium组件.
起初我认为这个图有点奇怪,我应该能够从其他网站获得更好的图表.我惊讶地发现互联网上的几乎所有Selenium RC设置图都与此图(克隆)类似.没有人曾试图为Selenium RC设置创建不同的图表或提供更多描述.
感谢是否有人可以给我如何设置Selenium RC的指导.我想知道的事情是:
selenium automation automated-tests selenium-ide selenium-rc
有没有人有使用Selenium自动测试使用Facebook Connect进行用户登录的webapp的经验?您推荐的任何提示或方法?
Selenium无法启动IE.
10:56:25,005 INFO [org.openqa.selenium.server.SeleniumDriverResourceHandler] Command request: getNewBrowserSession[*iexploreproxy, http://192.168.132.105:8080/, ] on session null
10:56:25,005 INFO [org.openqa.selenium.server.BrowserSessionFactory] creating new remote session
10:56:25,005 INFO [org.openqa.selenium.server.BrowserSessionFactory] Allocated session 9fa93fe865904e3da895c91a86ebdcb0 for http://192.168.132.105:8080/, launching...
10:56:25,005 INFO [org.openqa.selenium.server.browserlaunchers.WindowsProxyManager] Modifying registry settings...
10:56:25,474 INFO [org.openqa.selenium.server.browserlaunchers.InternetExplorerCustomProxyLauncher] Launching Internet Explorer...
之后Internet Explorer...它不会回应.请帮我解决这个问题.
selenium selenium-grid selenium-ide selenium-rc selenium-webdriver
我是Selenium的新手,我对版本号有点困惑. Selenium 2.0于2011年发布.我刚刚下载了Selenium IDE Firefox扩展,它是版本1.7.2.是否还有2.0的版本IDE,或者是1.x系列容易混淆地包含2.0代码?
我检查了Selenium HQ,它说明1.7.2目前是Selenium IDE的最新版本.
我用PHPUnit扩展编写了一个测试用例Selenium2TestCase.它确实很好用,但我无法弄清楚make如何在各种浏览器上自动运行此测试.
有一种方法setBrowser()只适用于setUp()方法.我想过这样的事情:
/**
* @dataProvider browsers
*/
public function loginTest($browser) {
$this->setBrowser($browser);
// tests...
}
Run Code Online (Sandbox Code Playgroud)
但我不行.尝试运行默认浏览器(可能我的Safari有点乱,上次使用firefox)
RuntimeException: Safari could not be found in the path!
Please add the directory containing ''Safari'' to your PATH environment
variable, or explicitly specify a path to Safari like this:
*safari /blah/blah/Safari
Run Code Online (Sandbox Code Playgroud)
PS.SeleniumTestCase(不是基于webdriver)提供了一个xml配置,我们可以在其中指定浏览器.Selenium2TestCase不支持它.
欢迎任何建议.谢谢.马尔钦
selenium-rc ×10
selenium ×7
selenium-ide ×5
apache ×1
automation ×1
c# ×1
click ×1
cookies ×1
facebook ×1
java ×1
phpunit ×1
python ×1
redirect ×1
testng ×1