我正在使用Selenium IDE for Firefox并搜索wait命令.我的问题是我想测试一个嵌入了外部地图的网站.此外部地图需要3-5秒才能加载.
我的命令:
open /Page/mysite.html
//Wait Command? (5 seconds)
ClickAndWait link=do something
Run Code Online (Sandbox Code Playgroud) 我找不到与Chrome兼容的Selenium IDE.
有谁知道使用Selenium IDE与Chrome而不是Firefox的方式?或者有没有可以与Chrome一起使用的替代工具?
我需要使用Selenium命令单击警报窗口内的"确定"按钮.我已经尝试过assertAlert
,verifyAlert
但他们没有做我想做的事.
单击"确定"按钮是否可能?如果是这样,有人能为我提供Selenium IDE命令的示例吗?
我试图在Python中运行Selenium Webdriver脚本来执行一些基本任务.当通过Selenium IDE界面运行时,我可以让机器人完美地运行(即:当简单地让GUI重复我的动作时).但是,当我将代码导出为Python脚本并尝试从命令行执行时,Firefox浏览器将打开但无法访问起始URL(错误将返回到命令行并且程序停止).无论我试图访问什么网站等,这都发生在我身上.
我在这里包含了一个非常基本的代码用于演示目的.我不认为我已正确包含代码的代理部分,因为返回的错误似乎是由代理生成的.
任何帮助将非常感激.
以下代码仅用于打开www.google.ie并搜索"selenium"一词.对我来说它打开一个空白的Firefox浏览器并停止.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re
from selenium.webdriver.common.proxy import *
class Testrobot2(unittest.TestCase):
def setUp(self):
myProxy = "http://149.215.113.110:70"
proxy = Proxy({
'proxyType': ProxyType.MANUAL,
'httpProxy': myProxy,
'ftpProxy': myProxy,
'sslProxy': myProxy,
'noProxy':''})
self.driver = webdriver.Firefox(proxy=proxy)
self.driver.implicitly_wait(30)
self.base_url = "https://www.google.ie/"
self.verificationErrors = []
self.accept_next_alert = True
def test_robot2(self):
driver = self.driver
driver.get(self.base_url + "/#gs_rn=17&gs_ri=psy-ab&suggest=p&cp=6&gs_id=ix&xhr=t&q=selenium&es_nrs=true&pf=p&output=search&sclient=psy-ab&oq=seleni&gs_l=&pbx=1&bav=on.2,or.r_qf.&bvm=bv.47883778,d.ZGU&fp=7c0d9024de9ac6ab&biw=592&bih=665")
driver.find_element_by_id("gbqfq").clear()
driver.find_element_by_id("gbqfq").send_keys("selenium")
def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except …
Run Code Online (Sandbox Code Playgroud) 使用"HTML"Selenium测试(使用Selenium IDE或手动创建),您可以使用一些非常方便的命令,如WaitForElementPresent
或WaitForVisible
.
<tr>
<td>waitForElementPresent</td>
<td>id=saveButton</td>
<td></td>
</tr>
Run Code Online (Sandbox Code Playgroud)
在用Java编写Selenium测试时(Webdriver/Selenium RC-我不确定这里的术语),是否有类似内置的东西?
例如,用于检查对话框(需要一段时间才能打开)是可见的...
WebElement dialog = driver.findElement(By.id("reportDialog"));
assertTrue(dialog.isDisplayed()); // often fails as it isn't visible *yet*
Run Code Online (Sandbox Code Playgroud)
编码此类检查的最简洁的方法是什么?
Thread.sleep()
在整个地方添加调用将是丑陋和脆弱的,并且滚动自己的while循环似乎也非常笨拙...
为什么我们不能在Selenium IDE中记录所有测试用例,将其导出到Java/WebDriver并使用Eclipse在WebDriver中运行它?
我需要一个明确的解释,因为我在使用WebDriver时非常困惑!
任何人都可以解释为什么IDE记录的脚本在WebDriver中失败了吗?
我一直在Selenium IDE中测试.它非常易于使用,我用它创建了一些测试用例.我一直在搜索Google,试图找到一种自动重复测试的方法.我已经看到了一个带有gotolabel的解决方案,而循环等等.但是我无法使它们中的任何一个工作.有人可以给我一个如何循环我的测试n
时间,或永远循环的提示.我感谢任何帮助.
我正在使用Selenium IDE为我的网站编写测试,我在使用previous-sibling点击按钮时遇到了麻烦
<td>
<div class="btn-group">
<button class="btn btn btn-danger block" title="Warning, Delete" name="delete" type="button">
<button class="btn btn btn-default block" title="View History" name="history" type="button">
<button class="btn btn btn-default block" title="View Settings" name="settings" type="button">
<button class="btn btn btn-default block" name="device" type="button">
<span class="glyphicon glyphicon-pencil"/>
Arcade Reader
</button>
</div>
</td>
Run Code Online (Sandbox Code Playgroud)
我自己的路
xpath=//button[contains(.,'Arcade Reader')]/../preceding-sibling::button[@name='settings']
Run Code Online (Sandbox Code Playgroud) 我刚刚将selenium IDE代码导出到selenium web驱动程序.我发现许多在IDE中工作的命令无法工作或者selenium web驱动程序声称根本不支持.到目前为止,我一直在解决这些问题,这个问题不太理想......
目前我正在努力找出为什么单击按钮不能与web驱动程序一起工作,因为它之前曾在selenium IDE中工作过.我的浏览器是FF 13,我的操作系统是Ubuntu.
代码片段
WebElement loginButton = driver.findElement(By.name("submit"));
loginButton.click();
Run Code Online (Sandbox Code Playgroud)
我之前尝试过
driver.findElement(By.name("submit")).click();
Run Code Online (Sandbox Code Playgroud)
但是上面的线路也失败了.该元素已被选中,但它不会按我的意愿登录.我发现其他页面有类似的问题,但他们的问题似乎是Internet Explorer而不是Firefox.我甚至不想考虑IE将给我带来的问题.
谢谢,
PS关于从selenium IDE迁移到Selenium Webdriver而不会丢失我编写的所有测试的更好方法的提示也可以解决这个问题.
我在同一页面上有2个按钮取消和下一个按钮,但它只有一个ID(参见下面的代码).我想按下Next但每次只识别取消按钮而不是下一步按钮.如何解决这个问题?
<td align="center">
<input type="button" id="cancelButton" value="Cancel" title="cancel" class="Submit_Button" style="background-color: rgb(0, 0, 160);">
<input type="submit" value="Next" title="next" class="Submit_Button">
</td>
Run Code Online (Sandbox Code Playgroud) selenium-ide ×10
selenium ×7
webdriver ×2
alert ×1
buttonclick ×1
firefox ×1
java ×1
proxy ×1
python ×1
selenium-rc ×1
testing ×1
xpath ×1