Tag: webdriver

我怎样才能得到webdriver中的元素的当前内容

我一定在想这个错误。 我想在WebDriver / Selenium 2访问的页面上获取元素的内容,在这个例子中是一个formfield 这是我的破碎的代码: Element=driver.find_element_by_id(ElementID) print Element print Element.text 这里是结果: <selenium.webdriver.remote.webelement.WebElement object at 0x9c2392c> (注意空白行)我知道这个元素有内容,因为我用前面的命令使用.sendkeys将它们填充在那里,当脚本运行时,我可以在实际的网页上看到它们。 但是我需要将内容重新存入数据。 我能做些什么来读这个? 最好以通用的方式,以便我可以从不同types的元素中提取内容。

selenium2.0b3 IE WebDriver,点击不发射

当IE9使用IE驱动时,偶尔Click方法只会select一个button,不会执行Click()的操作。 注意这只是偶尔发生,所以我不认为这是代码是问题。 在Firefox4中使用Firefox驱动程序没有问题。 我也有一个问题,元素偶尔也没有find,但只在IE浏览器,而不是Firefox。 if (Driver.FindElement(By.Name("username")) == null) { //sometimes gets here in IE, never gets here in Firefox } Driver.FindElement(By.Name("username")).SendKeys(username); Driver.FindElement(By.Name("surname")).SendKeys(surname); Driver.FindElement(By.Name("firstname")).SendKeys(firstname); string url = Driver.Url; Driver.FindElement(By.Name("cmd")).Click(); if (Driver.Url == url) { //if the page didnt change, click the link again Driver.FindElement(By.Name("cmd")).Click(); } 我见过这个类似的问题(http://stackoverflow.com/questions/4737205/selenium-webdriver-ie-button-issue),但我没有dynamic生成的id。

如何在Selenium WebDriver中设置浏览器的宽度和高度?

我正在使用Selenium WebDriver for Python。 我想用特定的宽度和高度实例化浏览器。 到目前为止,我能得到的最接近的是: driver = webdriver.Firefox() driver.set_window_size(1080,800) 哪些工作,但创build后设置浏览器的大小,我希望它在实例化设置。 我猜测这里有一个方法: profile = webdriver.FirefoxProfile(); profile.set_preference(foo, 1080) driver = webdriver.Firefox(profile) 但是我不知道foo会是什么,我不知道文档在哪里。 问:有没有办法在实例化时设置宽度/高度? Q2:参考文档在哪里列出了profile.set_preference可用的所有密钥?

webdriver.get()和webdriver.navigate()之间的区别

get()和navigate()方法有什么区别? 这个或者其他方法是否等待页面内容加载? 我真正需要什么是像seleniums 1.0 WaitForPageToLoad, but for using via webdriver` but for using via 。 有什么build议么?

黄瓜和水豚,点击一个非链接或button元素

我试图使用黄瓜/水豚/selenium堆testing就地编辑器,但我的问题是,通过单击一个div而不是一个链接或button来激活编辑器。 我似乎无法弄清楚如何让水豚做到这一点。 有没有办法做到这一点?

如何使用WebDriver检查警报是否存在?

我需要在WebDriver中检查Alert的存在。 有时会popup警报,但有时候不会popup。 我需要检查警报是否存在,然后我可以接受或解雇它,否则会说:没有发现警报。

为什么我们使用WebDriver而不是Selenium IDE?

为什么我们不能在Selenium IDE中logging所有的testing用例,将它导出到Java / WebDriver并在Eclipse中使用WebDriver运行? 我需要一个清晰的解释,因为我非常困惑的使用WebDriver! 任何人都可以请解释为什么WebDriver的IDElogging脚本失败?

如何隐藏Firefox窗口(Selenium WebDriver)?

当我同时执行多个testing时,我不想保持Firefox浏览器窗口可见..我可以使用selenium.minimizeWindow()尽量减less它,但我不想这样做。 有什么办法可以隐藏Firefox窗口? 我正在使用FireFox WebDriver。

如何修复seleniumWebDriverException:浏览器似乎退出之前,我们可以连接?

我在我的centos6.4服务器上安装了firefox和xvfb来使用selenium webdriver。 但是,当我运行代码时,我得到一个错误。 from selenium import webdriver browser = webdriver.Firefox() 错误 selenium.common.exceptions.WebDriverException: Message: 'The browser appears to have exited before we could connect. The output was: None' 我读了一些相关的页面在stackoverflow和有人build议删除tmp文件夹中的所有文件,所以我做到了。 但是,它仍然不起作用。 任何人都可以请给我一个帮助? 先谢谢你! 编辑 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.4/site-packages/selenium/webdriver/firefox/webdriver.py", line 59, in __init__ self.binary, timeout), File "/usr/local/lib/python3.4/site-packages/selenium/webdriver/firefox/extension_connection.py", line 47, […]

如何使用Selenium WebDriver C#从下拉菜单中select一个选项?

我正在尝试为我的networkingtestingselect一个选项。 一个例子可以在这里find: http : //www.tizag.com/phpT/examples/formex.php 除了select一个选项部分,一切都很好。 如何按价值或标签select一个选项? 我的代码: using OpenQA.Selenium.Firefox; using OpenQA.Selenium; using System.Collections.ObjectModel; using System.Text.RegularExpressions; using System.Threading; using System.Diagnostics; using System.Runtime.InteropServices; class GoogleSuggest { static void Main() { IWebDriver driver = new FirefoxDriver(); //Notice navigation is slightly different than the Java version //This is because 'get' is a keyword in C# driver.Navigate().GoToUrl("http://www.tizag.com/phpT/examples/formex.php"); IWebElement query […]