草庐IT

webdriver-w3c-spec

全部标签

python - 使用 PhantomJS 运行 Selenium Webdriver 时出现 InvalidElementStateException

我正在运行在Firefox中运行正常的selenium测试,但在使用PhantomJS时出现错误。这是我的python代码:driver.find_element_by_link_text("AddProvince").click()driver.find_element_by_id("id_name").clear()driver.find_element_by_id("id_name").send_keys("Frosinone")driver.find_element_by_id("id_code").clear()driver.find_element_by_id("id_co

python - Selenium 安装 Marionette webdriver

我的firefox版本47有这个问题https://github.com/seleniumhq/selenium/issues/2110因此,我尝试添加Marionette网络驱动程序来修复它:https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver但是:fromselenium.webdriver.common.desired_capabilitiesimportDesiredCapabilitiesfirefox_capabilities=DesiredCapabilities.FIREFOXf

python - 如何在 Windows 上使用 pip install 修复错误 “Expected version spec in …”?

在Windows7机器上,我使用以下命令从本地目录安装包:pipinstalladdons/pnc_tests--upgrade--extra-index-url=http://some_server/simple这会导致以下错误:C:\Users\alex\PNC\tas\ENV\Scripts\pip-script.pyrunon07/16/1407:50:47Exception:Traceback(mostrecentcalllast):File"C:\Users\alex\PNC\tas\ENV\lib\site-packages\pip\basecommand.py",lin

python - Selenium webdriver 和 unicode

这是我使用Selenium2库的第二天,Unicode带来的痛苦似乎从未消退。我只是做最基本的操作,想打印页面源码:fromseleniumimportwebdriverdriver=webdriver.Firefox()driver.get("http://google.com")printdriver.page_source果然报错了:UnicodeEncodeError:'ascii'codeccan'tencodecharacteru'\u0119'inposition62045:ordinalnotinrange(128)我怎样才能将其编码为utf-8?

python - 如何使用 python 在 selenium webdriver 中将 cookie 设置为特定域?

您好StackOverflow用户。我想要实现的是防止在我的测试打开主页时弹出烦人的帮助框。到目前为止,这是我用来打开主页的方法:defopen_url(self,url):"""OpenaURLusingthedriver'sbaseURL"""self.webdriver.add_cookie({'name':'tour.index','value':'complete','domain':self.store['base']+url})self.webdriver.add_cookie({'name':'tour.map','value':'complete','domain':

python - 根据 cron spec 计算下一个预定时间

在给定当前时间和cron规范的情况下,计算事件下一次运行时间的有效方法是什么?除了“每分钟循环检查它是否符合规范”之外,我正在寻找其他东西。规范示例可能是:每月1号和15号15:01在每小时的10、20、30、40、50分钟Python代码会很不错,但伪代码或高级描述也很受欢迎。[更新]假设规范已经被解析并且采用了某种合理的格式。 最佳答案 只是看看它,我认为你需要:将chron规范解析为包含每个字段可接受值的五个数组;将“现在”解析为每个字段的值;按分钟、小时、{day-of-monthORday-of-week}、month-o

python - 如何使用 Python 和 Selenium WebDriver 获取 localStorage

什么等同于:driver.get_cookies()获取LocalStorage而不是Сookies? 最佳答案 pythonAPI不提供直接读取/写入本地存储的方法,但可以使用execute_script完成。classLocalStorage:def__init__(self,driver):self.driver=driverdef__len__(self):returnself.driver.execute_script("returnwindow.localStorage.length;")defitems(self):r

python - 将现有的 Webdriver 对象传递给机器人框架的自定义 Python 库

我正在尝试为RobotFramework创建一个自定义Python库,但我是Python和Robot的新手,我不确定如何完成我想做的事情。我想将Robot使用Selenium2Library创建的Webdriver对象传递到我的自定义Python库,以便我可以使用Webdriver的方法,例如find_element_by_id。我看到了一些关于如何操作的建议here和here,但它们适用于Java库-我找不到任何Python说明。我将如何在Python中执行此操作?或者我想以不同的方式执行此操作,而不传递Webdriver对象? 最佳答案

python - 在 Selenium Webdriver 中呈现页面后禁用 Javascript

我正在使用Python。我看过HowcanIdisablejavascriptinfirefoxwithselenium?它说要创建一个配置文件,然后使用该配置文件加载驱动程序。但是我想在呈现页面后禁用Javascript,所以这意味着我无法重新创建驱动程序。我试过以下方法:browser=selenium.webdriver.Firefox()browser.get('http://wwwhatever.com')browser.firefox_profile.set_preference('javascript.enabled',False)browser.firefox_prof

python - 使用带有扩展名(.crx 文件)的 Python 运行 Selenium WebDriver

我去了ChromeExtensionDownloader获取“Adblock-Plus_v1.4.1”的.crx文件。我把它放到我正在工作的目录中,然后运行:fromseleniumimportwebdriverchop=webdriver.ChromeOptions()chop.add_extension('Adblock-Plus_v1.4.1.crx')driver=webdriver.Chrome(chrome_options=chop)它完全承认它的存在,但它给了我一个看起来像ChromeDriver.exe风格的消息:ERROR:extension_error_report