我是编程的新手,Python大约2个月前开始使用Python文本,正在浏览Sweigart的自动化无聊的东西.我正在使用IDLE并且已经安装了selenium模块和Firefox浏览器.每当我尝试运行webdriver函数时,我都会得到:
from selenium import webdriver
browser = webdriver.Firefox()
Run Code Online (Sandbox Code Playgroud)
例外: -
Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x00000249C0DA1080>>
Traceback (most recent call last):
File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 163, in __del__
self.stop()
File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 135, in stop
if self.process is None:
AttributeError: 'Service' object has no attribute 'process'
Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x00000249C0E08128>>
Traceback (most recent call last):
File "C:\Python\Python35\lib\site-packages\selenium\webdriver\common\service.py", line 163, in __del__
self.stop()
File …Run Code Online (Sandbox Code Playgroud) 我在使用Firefox和WebDriver时遇到错误.
org.openqa.selenium.firefox.NotConnectedException: Unable to connect
to host 127.0.0.1 on port 7055 after 45000 ms.
Run Code Online (Sandbox Code Playgroud)
有人得到类似的问题或任何想法是什么解决方案?它适用于Chrome,但使用Firefox时,没有任何网址被加载.
java firefox selenium selenium-firefoxdriver selenium-webdriver
我现在正在学习Selenium,遇到了一个问题.
我知道Selenium默认支持旧的Firefox版本,没有驱动程序.对于最新版本的Firefox,我们必须下载驱动程序并使用它来定义它System.setProperty.
根据此链接,对于Firefox 45和46,启动驱动程序代码可能如下所示:
WebDriver driver = new FirefoxDriver();
Run Code Online (Sandbox Code Playgroud)
我的Firefox版本为45.5.1.但是上面的代码仍然不起作用.所以根据这个链接,我添加了:
System.setProperty("webdriver.firefox.marionette","C:\\geckodriver.exe");
它奏效了.
然后我意识到我没有安装geckodriver.exe在我的电脑上.要了解它是如何进行的,我已经更改为以下代码:
System.setProperty("webdriver.firefox.marionette","");
Run Code Online (Sandbox Code Playgroud)
它仍然有效.
所以,这是我的第一个问题:发生了什么?我确信geckodriver.exe在我的环境中不存在.如果没有指出位置,那我为什么要设置属性?
另外,我见过的代码如下:
System.setProperty("webdriver.gecko.driver", "/tools/marionette/wires.exe");
Run Code Online (Sandbox Code Playgroud)
我的第二个问题是,是什么样的区别webdriver.gecko.driver 和webdriver.firefox.marionette或wires.exe和geckodriver.exe?
selenium selenium-firefoxdriver selenium-webdriver firefox-marionette geckodriver
如何为FF暂时禁用这个"首次运行"页面?
创建FF驱动程序时,它会打开选项卡,其中包含 - https://www.mozilla.org/en-US/firefox/42.0/firstrun/learnmore/ 以及带有目标页面的附加选项卡.
我试图通过Selenium 刮掉这个网站.
我想点击"下一页"按钮,为此我这样做:
driver.find_element_by_class_name('pagination-r').click()
Run Code Online (Sandbox Code Playgroud)
它适用于许多页面但不适用于所有页面,我收到此错误
WebDriverException: Message: Element is not clickable at point (918, 13). Other element would receive the click: <div class="linkAuchan"></div>
Run Code Online (Sandbox Code Playgroud)
总是为这个页面
我读了这个问题
我试过这个
driver.implicitly_wait(10)
el = driver.find_element_by_class_name('pagination-r')
action = webdriver.common.action_chains.ActionChains(driver)
action.move_to_element_with_offset(el, 918, 13)
action.click()
action.perform()
Run Code Online (Sandbox Code Playgroud)
但我得到了同样的错误
python selenium web-scraping selenium-firefoxdriver selenium-webdriver
哪个Firefox版本与Selenium 2.53.0兼容?我尝试了Firefox 45.0,我得到了这个例外:
org.openqa.selenium.WebDriverException: Failed to connect to binary
FirefoxBinary(/Applications/Firefox.app/Contents/MacOS/firefox-bin) on port 7055; process output follows:
foreignInstall":false,"hasBinaryComponents":false,"strictCompatibility":false,"l ocales":[],"targetApplications":[{"id":"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}","minVersion":"45.0","maxVersion":"45.*"},{"id":"xpcshell@tests.mozilla.org","minVersion":"0","maxVersion":"10"}],"targetPlatforms":[],"multiprocessCompatible":false,"seen":true}
Run Code Online (Sandbox Code Playgroud) 看到很多关于Selenium 2.53.1和Firefox 47.0.1的问题,但没有关于Selenium 3 Beta版本的问题.我正在尝试使用新的gecko/marionette Firefox webdrivers,但即使我有驱动程序位置; 我的环境路径,Firefox在程序中安装文件夹,并在系统环境中给出驱动器位置,它仍然无法正常工作.
错误:
geckodriver.exe不存在于当前目录或PATH环境变量的目录中.该驱动程序可以从https://github.com/mozilla/geckodriver/releases下载.
使用:
示例代码1
using OpenQA.Selenium.Firefox;
public static class FirefoxInitialise
{
public static IWebDriver Driver {get; set;}
Driver = new FirefoxDriver();
}
Run Code Online (Sandbox Code Playgroud)
还尝试了以下内容:
using OpenQA.Selenium.Firefox;
public static class FirefoxInitialise
{
public static IWebDriver Driver {get; set;}
FirefoxDriverServices service = FirefoxDriverService.CreateDefaultService();
service.FirefoxBinaryPath = @"C:\Program Files\Mozilla Firefox\firefox.exe";
FirefoxOptions options = new FirefoxOptions();
TimeSpan time = TimeSpan.FromSeconds(10);
Driver = new FirefoxDriver(service, options, time);
} …Run Code Online (Sandbox Code Playgroud) c# firefox selenium selenium-firefoxdriver selenium-webdriver
上周,这款名为Marionette的新FirefoxDriver出现了很多噪音.要将Firefox与Selenium一起使用,我们过去常常使用"旧的"Selenium FirefoxDriver.从Firefox 48.0开始,将需要使用由Mozilla开发的这个新的FirefoxDriver.
我知道需要改变这个方向以获得每个浏览器支持并开发其驱动程序并使驱动程序独立于Selenium.此外,假设Mozilla开发自己的驱动程序,它将更快,更容易地解决问题和开发功能.
我的问题是,对于那些使用Selenium框架创建自动化测试的人来说,使用Marionette而不是"旧的"Selenium支持的FirefoxDriver有什么好处吗?_(比如更好的性能,更好的兼容性......)
selenium selenium-firefoxdriver selenium-webdriver firefox-marionette
我在C#开始了一个Selenium项目.尝试等待页面完成加载,然后才进行下一步操作.
我的代码看起来像这样:
loginPage.GoToLoginPage();
loginPage.LoginAs(TestCase.Username, TestCase.Password);
loginPage.SelectRole(TestCase.Orgunit);
loginPage.AcceptRole();
Run Code Online (Sandbox Code Playgroud)
在loginPage.SelectRole(TestCase.Orgunit)中:
RoleHierachyLabel = CommonsBasePage.Driver.FindElement(By.XPath("//span[contains(text(), " + role + ")]"));
RoleHierachyLabel.Click();
RoleLoginButton.Click();
Run Code Online (Sandbox Code Playgroud)
我搜索元素RoleHierachyLabel.我一直在尝试使用多种方式等待页面加载或搜索元素属性允许一些超时:
1. _browserInstance.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
Run Code Online (Sandbox Code Playgroud)
2. public static bool WaitUntilElementIsPresent(RemoteWebDriver driver, By by, int timeout = 5)
{
for (var i = 0; i < timeout; i++)
{
if (driver.ElementExists(by)) return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
你会如何解决这个障碍?
c# pageload ui-automation selenium-firefoxdriver selenium-webdriver
我正在使用Selenium webdriver与某些网站进行交互.
如果网站使用jQuery,我们可以通过使用获取待处理的AJAX请求jQuery.active.
JavascriptExecutor jsx = (JavascriptExecutor) driver;
Run Code Online (Sandbox Code Playgroud)
Int totAjaxRequest =(Int)jsx.executeScript("jQuery.active");
Int totAjaxRequest = (Int)jsx.executeScript("return jQuery.active");
Run Code Online (Sandbox Code Playgroud)
如果网站没有使用jQuery,我们如何计算XMLHttpRequest请求的数量.
javascript jquery selenium selenium-firefoxdriver selenium-webdriver
selenium ×9
firefox ×5
c# ×2
geckodriver ×2
python ×2
java ×1
javascript ×1
jquery ×1
pageload ×1
web-scraping ×1