草庐IT

webdriver-helper

全部标签

javascript - 如何从 Selenium Webdriver 获取异步 Javascript 响应

我们在我们的网站上添加了一个异步javascript调用。我正在尝试让SeleniumWebdriver等待调用的响应。监听器看起来像这样:$(document).on("application:subapp:rendered",function(){console.log("foo");});我的webdriver代码(python):driver.set_script_timeout(30)response=driver.execute_async_script("$(document).on(\"application:subapp:rendered\",function(){r

python - 在 OS X 中使用 Selenium WebDriver 打开和关闭新选项卡

我在Windows上使用Python2.7中的FirefoxWebdriver来模拟打开(Ctrl+t)和关闭(Ctrl+w)新标签页。这是我的代码:fromseleniumimportwebdriverfromselenium.webdriver.common.keysimportKeysbrowser=webdriver.Firefox()browser.get('https://www.google.com')main_window=browser.current_window_handle#opennewtabbrowser.find_element_by_tag_name('

python Selenium : How to check whether the WebDriver did quit()?

我想控制我的WebDriver是否退出,但我找不到相应的方法。(ItseemsthatinJavathere'sawaytodoit)fromseleniumimportwebdriverdriver=webdriver.Firefox()driver.quit()driver#driverisNone#False我还探索了WebDriver的属性,但找不到任何特定方法来获取有关驱动程序状态的信息。同时检查sessionID:driver.session_id#u'7c171019-b24d-5a4d-84ef-9612856af71b' 最佳答案

Python Selenium Webdriver - 代理身份验证

我想将SeleniumWebdriver与需要用户身份验证的代理一起使用。这可能吗?这是我到目前为止所拥有的,但我不知道将凭据放在哪里(user:pass@proxy:port)fromseleniumimportwebdriverprofile=webdriver.FirefoxProfile()profile.set_preference("network.proxy.type",1)profile.set_preference("network.proxy.http","proxy")profile.set_preference("network.proxy.http_port"

python - 如何在单个 session 中多次更改我的 webdriver 上的代理?

我正在开发一个机器人。我希望机器人每50次搜索更改一次webdriver的代理。我有一个请求代理和套接字的API,我存储了这些变量,到目前为止我一直在使用firefox配置文件来设置它,但效果不是很好。考虑到我已经有了一个可行的代理和端口来源,你能告诉我有什么方法可以更改代理而不会使webdriver崩溃并在单个session中完成吗?以前的尝试:我试过这样设置firefox配置文件:regions={'US':'',#USAisthedefaultserver'Australia':#jsonresponsethroughtheapi,'Canada':#jsonresponseth

python - 如何使用带有 python 的 Selenium WebDriver 获取 Web 元素的颜色?

如何定位十六进制格式的网络元素的背景颜色?使用我当前的seleniumwebdriverpython代码,它以RGB格式返回背景颜色。这是我正在查看的html元素divclass="bar"style="background-color:#DD514C;background-image:-moz-linear-gradient(centertop,#EE5F5B,#C43C35);background-image:-webkit-linear-gradient(top,#EE5F5B,#C43C35);background-image:-ms-linear-gradient(top,#

python - 使用 Headless Chrome Webdriver 运行 Selenium

所以我正在用selenium尝试一些东西,我真的希望它快点。所以我的想法是使用headlesschrome运行它会使我的脚本更快。首先,这个假设是否正确,或者我是否使用headless驱动程序运行我的脚本无关紧要?无论如何,我仍然想让它headless运行,但不知何故我做不到,我尝试了不同的方法,大多数人建议它会像10月更新中所说的那样工作HowtoconfigureChromeDrivertoinitiateChromebrowserinHeadlessmodethroughSelenium?但是当我尝试这样做时,我得到了奇怪的控制台输出并且它似乎仍然不起作用。感谢任何提示。

python - selenium.wait_for_condition 等效于 WebDriver 的 Python 绑定(bind)

我正在将一些测试从Selenium转移到WebDriver。我的问题是我找不到selenium.wait_for_condition的等效项。Python绑定(bind)目前是否有此功能,还是仍在计划中? 最佳答案 目前无法将wait_for_condition与WebDriver一起使用。pythonselenium代码确实提供了DrivenSelenium类来访问旧的selenium方法,但它不能执行wait_for_condition。Theseleniumwikihassomeinfoonthat.最好的办法是使用WebDr

python - 我可以使用 selenium webdriver 读取浏览器 url 吗?

我正在使用python2.7和beautifulSoup4和Seleniumwebdriver。现在在我的webautomation脚本中,我将打开链接或URL并进入主页。现在我需要点击一些anchorLabels来浏览其他页面。我一直这样做到现在。现在,当我要转到一个新页面时,我需要从浏览器获取新的URL,因为我需要将它传递给BeautifulSoup4以进行网页抓取。所以现在我关心的是如何以动态方式获取此类URL?如有请指教! 最佳答案 您在驱动程序上获得current_url属性:fromseleniumimportwebdr

python - 属性错误 : 'list' object has no attribute 'click' - Selenium Webdriver

我正在尝试使用python在Seleniumwebdriver中使用click命令。但我收到以下错误。有人可以帮助我吗?Traceback(mostrecentcalllast):File"C:\Users\vikram\workspace\LDC\test.py",line13,indriver.find_elements_by_link_text("MISCQAMiscTests").click()AttributeError:'list'objecthasnoattribute'click'这是我的程序fromseleniumimportwebdriverfromselenium