有谁知道是否可以使用Selenium WebDriver截取屏幕截图?(注:不是Selenium RC)
selenium selenium-webdriver ashot takesscreenshot selenium-shutterbug
我想用字符串中的下划线替换空格来创建漂亮的URL.例如:
"This should be connected" becomes "This_should_be_connected"
Run Code Online (Sandbox Code Playgroud)
我正在使用Python与Django.这可以使用正则表达式解决吗?
我有硒chromedriver的问题,我无法弄清楚是什么导致它.几周前一切正常,但突然出现这个错误.问题来自以下功能.
def login_(browser):
try:
browser.get("some_url")
# user credentials
user = browser.find_element_by_xpath('//*[@id="username"]')
user.send_keys(config('user'))
password = browser.find_element_by_xpath('//*[@id="password"]')
password.send_keys(config('pass'))
login = browser.find_element_by_xpath('/html/body/div[1]/div/button')
login.send_keys("\n")
time.sleep(1)
sidebar = browser.find_element_by_xpath('//*[@id="sidebar"]/ul/li[1]/a')
sidebar.send_keys("\n")
app_submit = browser.find_element_by_xpath('//*[@id="sidebar"]/ul/li[1]/ul/li[1]/a')
app_submit.send_keys("\n")
except TimeoutException or NoSuchElementException:
raise LoginException
Run Code Online (Sandbox Code Playgroud)
此功能在开发环境(macOS 10.11)中没有问题,但在生产环境中引发以下错误:
Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="sidebar"]/ul/li[1]/a"}
(Session info: headless chrome=67.0.3396.79)
(Driver info: chromedriver=2.40.565383 (76257d1ab79276b2d53ee97XXX),platform=Linux 4.4.0-116-generic x86_64)
Run Code Online (Sandbox Code Playgroud)
我已经在每个环境中更新了Chrome和chromedriver(分别为v67和2.40).我也给了它更多time.sleep(15).但问题仍然存在.我最新的猜测是,webdriver的初始化可能无法正常工作:
def initiate_webdriver():
option = webdriver.ChromeOptions()
option.binary_location = config('GOOGLE_CHROME_BIN')
option.add_argument('--disable-gpu')
option.add_argument('window-size=1600,900')
option.add_argument('--no-sandbox')
if not config('DEBUG', cast=bool):
display = Display(visible=0, size=(1600, 900))
display.start() …Run Code Online (Sandbox Code Playgroud) python selenium selenium-chromedriver selenium-webdriver webdriverwait
我正在使用Robot Framework来自动化网站.本网站使用Silverlight应用程序显示视频.
我的目标: 在我的机器人框架中创建一个自定义关键字,它采用一个web元素,web元素是Silverlight播放器在页面上的位置,并截取可见内容.我不需要与Silverlight应用程序进行交互.
已完成工作:
我已经创建了一个自定义关键字Capture Screenshot Of Element,它接受一个网页元素并返回该特定元素的屏幕截图.但是,如果元素包含Silverlight应用程序,则我返回的所有内容都是空白背景颜色,而不是Silverlight应用程序上显示的图像.
有没有办法在浏览器中指定Web元素并显示该元素在屏幕上实际显示的内容?
python silverlight selenium robotframework selenium-webdriver
我正在使用tumblr测试我的应用程序,我必须在我执行程序时登录和注销.在这样做时,我无法点击一个不断弹出的复选框.如何在python中使用selenium-webriver点击它?
我已经尝试过选择xpaths,... by_ids和by_classes,它们将无法工作,所以现在我正在尝试使用鼠标坐标来物理点击该项目.(这是在tumblr登录页面,fyi)
以上是我想要选择的项目的html.
(编辑:)我有以下选择器:
#checkbox = driver.find_element_by_id("recaptcha-anchor")
#checkbox = driver.find_element_by_id("g-recaptcha")
#driver.find_element_by_xpath("//*[@id='recaptcha-token']")
#driver.find_element_by_css_selector("#recaptcha-anchor")
#driver.find_element_by_xpath("//*[@id='recaptcha-anchor']")
#driver.find_element_by_id("recaptcha-token").click()
#driver.find_element_by_class_name('rc-anchor-center-container')
#checkbox = driver.find_element_by_id("recaptcha-anchor")
Run Code Online (Sandbox Code Playgroud)