草庐IT

webdriver-w3c-spec

全部标签

python - Scrapy with selenium, webdriver 无法实例化

我正在尝试将selenium/phantomjs与scrapy一起使用,但我遇到了很多错误。例如,采用以下代码片段:defparse(self,resposne):whileTrue:try:driver=webdriver.PhantomJS()#dosomestuffdriver.quit()breakexcept(WebDriverException,TimeoutException):try:driver.quit()exceptUnboundLocalError:print"Driverfailedtoinstantiate"time.sleep(3)continue很多时候

python - python package namespaces : z3c, zc, collective 背后是什么?

所以它们都以某种方式与zope相关。问题是如何?我不熟悉Zope。我猜zc、z3c代表ZopeComponent和Zope3Component但我想确定一下。还有一个collective命名空间。它下面有什么样的包裹?还有哪些其他众所周知的python包命名空间?当包应该使用zc、z3c和其他命名空间时,是否有任何约定?有时我看到包以zc开头,但我无法理解为什么它们要命名空间。例如z3c.sqlalchemy有命名空间,因为它是用于zope项目的sqlalchemy的包装器。但是另一个例子zc.buildout看起来像是一个完全独立的项目。它获得命名空间仅仅是因为它是由在Zope上工作

python - 无法在python中的selenium webdriver中加载firefox

我已经安装了Python3.6.2,Selenium3.5.0和GeckoDriver0.18.0,Firefox版本在Windows7上是54.0.1。火狐版本错误。请让我知道问题出在哪里。下面是代码和错误信息。fromseleniumimportwebdriverfromselenium.webdriver.common.keysimportKeysfromselenium.webdriver.firefox.firefox_binaryimportFirefoxBinarycapabilities=webdriver.DesiredCapabilities().FIREFOXca

python - 在 python 中使用默认的 firefox 配置文件和 selenium webdriver

我知道以前有人问过类似的问题,但我已经尝试了很多次,但仍然对我不起作用。我在firefox中只有一个默认配置文件(称为c1r3g2wi.default),没有其他配置文件。当我使用seleniumwebdriver启动它时,我希望我的firefox浏览器以这个配置文件启动。我如何在Python中执行此操作?我这样做了:fp=webdriver.FirefoxProfile('C:\Users\admin\AppData\Roaming\Mozilla\Firefox\Profiles\c1r3g2wi.default')browser=webdriver.Firefox(fp)但是我得

Python selenium webdriver - 驱动程序突然出现 "dies"并且无法退出,获取 current_url,打开页面

有时,在我的脚本中间,我的webdriver实例会死掉!从那以后,我无法调用它的任何方法。一些例子:>>>spsel.driver.current_urlTraceback(mostrecentcalllast):File"",line1,inFile"/usr/local/lib/python2.6/dist-packages/selenium/webdriver/remote/webdriver.py",line414,incurrent_urlreturnself.execute(Command.GET_CURRENT_URL)['value']File"/usr/local/l

python - 使用 selenium webdriver 限制 phantomjs 的内存使用?

我在远程WebDriver模式下使用phantomjs--webdriver8910运行phantomjs,然后使用Seleniumpython绑定(bind)获取许多页面,例如:wd=webdriver.PhantomJS(port=8910)forurlinbig_url_list:wd.get(url)#dosomethinghere,e.g.wd.save_screenshotorprintwd.page_sourcewd.quit()wd.quit()似乎什么都不做。使用top监控进程显示,随着检索更多页面,phantomjs进程的内存使用量持续增加。如果我重新启动phant

Python - selenium webdriver 卡在 .get() 循环中

我有一个Python代码片段,它使用SeleniumWebdriver循环遍历一些历史棒球赔率。代码的第一部分旨在从时间表(由大约57个需要循环的页面组成)中获取所有单独的游戏URL,并将它们存储在一个列表中。我第一次测试它时它工作得很好-现在,无论出于何种原因,driver.get()函数似乎无法正常工作。发生的情况是webdriver在pageRange循环(第2页)中启动第一个.get()方法,但在那之后,在循环的下一次迭代中它被卡住并且不会导航到第3页。没有错误消息或崩溃。使用print()进行的一些手动错误检查表明代码的所有其他区域都运行良好。这个问题的潜在原因是什么?编辑1

python - 如何从 Google Chrome Selenium Webdriver 客户端获取 JSON 响应?

目前我将Selenium连接到python以抓取网页。我发现该页面实际上是从JSONAPI中提取数据,只要我登录到该页面,我就可以获得JSON响应。但是,我将响应输入python的方法似乎有点笨拙;我选择中包含的文本标签并使用python的json像这样解析数据的包:importjsonfromseleniumimportwebdriverurl='http://jsonplaceholder.typicode.com/posts/1'driver=webdriver.Chrome()driver.get(url)json_text=driver.find_element_by_css

python - 如何使用 webdriver 获取文本区域的文本内容?

我正在尝试获取textarea的内容在HTML表单中使用webdriverinPython.我正在获取文本,但缺少换行符。seleniumdocs几乎没用;他们说:classselenium.webdriver.remote.webelement.WebElement(parent,id_)[...]text:Getsthetextoftheelement.我目前正在做以下事情:fromseleniumimportwebdriver#openthebrowserandwebsiteb=webdriver.Firefox()b.get('http://www.example.com')#

python - Webdriver 是否支持 Python 的 pagefactory?

我正在阅读pageobjects和Webdriver项目网站上的设计模式并遇到了pagefactory.它看起来不像PythonAPI的Webdriver包含pagefactory。这是真的吗? 最佳答案 我认为在Python中没有任何Java注释(@Find(By.xxx)等)的等价物。但这并不意味着您不能使用PageObject模式。你可以在这里找到如何做的好例子:https://github.com/SeleniumHQ/selenium/blob/master/py/test/selenium/webdriver/commo