草庐IT

Watir-WebDriver

全部标签

Python 将 Adblock 与 Selenium 和 Firefox Webdriver 结合使用

我的目标是通过Python将AdblockPlus与Selenium结合使用。我已经能够让它加载扩展,但默认情况下它不包含默认过滤器“EasyList”。这是我目前所拥有的:fromseleniumimportwebdriverfromtimeimportsleepffprofile=webdriver.FirefoxProfile()adblockfile='/Users/username/Downloads/adblock_plus-2.4-tb+fx+an+sm.xpi'ffprofile.add_extension(adblockfile)ffprofile.set_prefe

Python Selenium 异常 AttributeError : "' Service' object has no attribute 'process' "in selenium. webdriver.ie.service.Service

我有一个SeleniumPython测试套件。它开始运行,但几分钟后抛出以下错误:ExceptionAttributeError:"'Service'objecthasnoattribute'process'"in>ignored我的测试套件实现是:importunittestfromHTMLTestRunner2importHTMLTestRunnerimportosimportRegression_TestCase.RegressionProject_TestCase2#getthedirectorypathtooutputreportfile#result_dir=os.getc

python - 有没有人用过Webdriver的ActionChains(python绑定(bind))?

我正在尝试使用ActionChains中的move_to_element触发鼠标悬停事件,但无法正常工作。任何帮助表示赞赏。谢谢。 最佳答案 fromselenium.webdriver.common.action_chainsimportActionChainsActionChains(drivers).move_to_element(drivers.find_element_by_id('element_id')).click().perform()如果你想选择任何值,menu1=drivers.find_element_by_

python - 如何使用带有 Python 的 Selenium WebDriver 获取选定的选项?

如何使用带有Python的SeleniumWebDriver获取选定的选项:有人对getFirstSelectedOption有解决方案吗?我正在使用它来获取选择元素:try:FCSelect=driver.find_element_by_id('FCenter')self.TestEventLog=self.TestEventLog+"VerifyFormElements:FCenterSelectfound"exceptNoSuchElementException:self.TestEventLog=self.TestEventLog+"Error:SelectFCenterele

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 - 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 - 如何使用 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对象? 最佳答案