通过硒.如何从文本框中删除内容.
我必须使用selenium命令从文本框中删除最后2个字符.
例如ABCD到AB.
如何告诉Selenium使用HTMLUnit?
我在后台运行selenium-server-standalone-2.0b1.jar作为Selenium服务器,并使用"pip install -U selenium"安装最新的Python绑定.
一切都适用于Firefox.但我想使用HTMLUnit,因为它重量更轻,不需要X.这是我尝试这样做的:
>>> import selenium
>>> s = selenium.selenium("localhost", 4444, "*htmlunit", "http://localhost/")
>>> s.start()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/selenium/selenium/selenium.py", line 189, in start
result = self.get_string("getNewBrowserSession", start_args)
File "/usr/local/lib/python2.6/dist-packages/selenium/selenium/selenium.py", line 223, in get_string
result = self.do_command(verb, args)
File "/usr/local/lib/python2.6/dist-packages/selenium/selenium/selenium.py", line 217, in do_command
raise Exception, data
Exception: Failed to start new browser session: Browser not supported: *htmlunit
Supported browsers include:
*firefox
*mock
*firefoxproxy
*pifirefox
*chrome
*iexploreproxy
*iexplore
*firefox3 …
Run Code Online (Sandbox Code Playgroud) 我正在使用Selenium RC使用Java与eclipse和TestNG框架.我有以下代码片段:
assertTrue(selenium.isTextPresent("Please enter Email ID"));
assertTrue(selenium.isTextPresent("Please enter Password"));
Run Code Online (Sandbox Code Playgroud)
第一个断言失败,执行停止.但我想继续进一步的代码片段.
关于自动化的问题 我用Selenium RC.
我将我的FF升级到3.6.18,似乎找不到任何内部有"contains()"的定位器
我读了很多论坛.这是一个已知问题,但我找不到任何解决方案.
那么现在用什么代替contains()呢?
我的测试课中有一个测试用例,并且有一些问题.我从控制台运行脚本.该脚本执行到某一点,然后测试失败,出现错误:
Could not connect to the Selenium RC server.
这是来自控制台的日志:
PHPUnit 3.5.15 by Sebastian Bergmann. E Time: 01:56, Memory: 4.00Mb There was 1 error: 1) someTest::testSomething PHPUnit_Framework_Exception: Could not connect to the Selenium RC server. /var/www/path.../someTest.php:105 FAILURES! Tests: 1, Assertions: 0, Errors: 1.
我的测试脚本中的第105行:
$this->clickAndWait("//a[text()='Next']");
这是Selenium日志:
14:00:40.983 INFO - Command request: click[//a[text()='Next'], ] on session 4222e17607254f41a6a52e13d0fd7cc5 14:00:41.205 INFO - Got result: OK on session 4222e17607254f41a6a52e13d0fd7cc5 14:00:41.207 INFO - Command request: waitForPageToLoad[600000000, ] on session 4222e17607254f41a6a52e13d0fd7cc5 14:02:11.328 INFO …
我正在使用selenium RC,我希望,例如,获取具有匹配的属性href的所有链接元素:
http://[^/]*\d+com
Run Code Online (Sandbox Code Playgroud)
我想用:
sel.get_attribute( '//a[regx:match(@href, "http://[^/]*\d+.com")]/@name' )
Run Code Online (Sandbox Code Playgroud)
这将返回与正则表达式匹配的所有链接的name属性列表.(或类似的东西)
谢谢
使用ASP.NET,标签ID非常不稳定,所以为了使我的测试更加健壮,我想通过标签文本定位元素.我已经和WatiN玩了一些并且完美地做到了这一点但是现在这个项目似乎有点死了所以我认为在决定框架之前我也会考虑Selenium.
我有html看起来像这样
<label for="ctl00_content_loginForm_ctl01_username">Username</label>:
<input type="text" id="ctl00_content_loginForm_ctl01_username" />
Run Code Online (Sandbox Code Playgroud)
我不想输入:
selenium.Type("ctl00_content_loginForm_ctl01_username", "xxx");
Run Code Online (Sandbox Code Playgroud)
这太依赖于身份证.在WatiN我会写:
browser.TextField(Find.ByLabelText("Username")).TypeText("xxx");
Run Code Online (Sandbox Code Playgroud)
有没有办法在Selenium做到这一点?
使用selenium-rc和java客户端,我想测试一个菜单,当用户将鼠标移到它上面时,该菜单会打开.当鼠标离开菜单时它会关闭.这是使用:hover
css 完成的,没有任何javascript.
在selenium中,有许多鼠标操作方法,但它们似乎都没有触发任何css :hover
样式.
谷歌表明我并不是唯一一个解决这个问题的人,但是没有一个解决方案.有些人评论说你必须添加一些javascript代码; 但是,在selenium rc中,我认为我甚至没有一个适当的位置来提供用户贡献的额外javascript代码.
我希望下面的代码可以工作,因为div#navi_settings包含的菜单包含 - 通常是不可见的 - 元素:
selenium.mouseHover("css=div#navi_settings");
assertTrue(selenium.isVisible("//a[contains(text(), 'Text on link')]"));
Run Code Online (Sandbox Code Playgroud)
不幸的是,该方法moveHover()
尚不存在.
我一直使用硒rc运行我的硒测试约6个月,并且当测试结束时,firefox windows selenium突然打开时不会关闭.
我正在使用特定的firefox配置文件,并没有更新我的selenium rc jar.我认为也许最新版本的firefox可能是问题但我恢复到firefox 2并且Windows仍然保持打开状态.
我在Windows机器上运行测试.
我注意到其他人似乎遇到了这个问题 - 只是想知道是否有人有解决方案?
谢谢,Gearoid.
我试图与硒2运行我的测试和Firefox 19.一个这个测试将导致错误"ERROR:命令执行失败的错误消息是:无法访问死对象".
我正在阅读它,它似乎是最新Firefox版本中的一个错误.很多人都有同样的问题,但我没有发现任何真正清楚的问题.
任何英雄都可以帮助我们吗?也许我们只需要改变"about:config"中的内容?
问候