[英]Python+selenium code works fine in Chrome, but not in Firefox
[英]Selenium - Python - same code works well with firefox but 10min slower with chrome
我想在可见/加载图像后单击一个按钮,该测试需要10分钟才能在具有Firefox的Chrome Vs 0:00:00.029671上运行。 它太慢了,我宁愿手动运行测试。 我怎样才能同时执行? 我很拼命,花了我几天的时间...来自互联网的多种代码解决方案
I upgrade google Chrome 75.0.3770.90 and ChromeDriver
I added some options to run chrome :(not very helpful in this case)
options.add_argument('--no-sandbox')
options.add_argument('--disable-gpu')
options.add_argument('start-maximized')
options.add_argument('disable-infobars')
options.add_argument("--disable-extensions")
connectionStatus = True
while connectionStatus == True:
try:
WebDriverWait(conn.driver, 10).until(ec.visibility_of_element_located(
(By.CSS_SELECTOR, "img[src='../public/images//disconnect.png']")))
element = conn.driver.find_element(By.CSS_SELECTOR, 'img[src="../public/images//disconnect.png"]')
element.is_displayed
print("disconnect")
connectionStatus = False
except NoSuchElementException as e:
print("Waiting for M to disconnect from VW")
time.sleep(10)
except TimeoutException:
print("TIMEOUT - Element not found: ")
conn.driver.find_element(By.CSS_SELECTOR, "#btnSendUpd").click()
执行:
Start: 2019-06-18 16:13:06.710734
TIMEOUT - Element not found:
Diff = 0:05:00.004450
disconnect
Diff = 0:05:00.046355
NB: the code html contains only css , not ID to use findElementById
Windows 10 - 64bits(I use chromedriver 32bits-they say that is working on 64bits)
Selenium 3.141.0
有人告诉我我正在测试的网站与Hidden Iframe(使用Javascript进行彗星编程)一起工作,动态Web应用程序的一项基本技术是使用隐藏的iframe HTML元素(内嵌框架,该元素可以使网站嵌入一个HTML文档)里面)。 此不可见的iframe以块块的形式发送,该块隐式地将其声明为无限长(有时称为“永远帧”)
我检查了“开发工具” => Network:就像脚本永远不会停止F12-Network-Chrome一样 ,我认为Chrome正在等待它完成,这就是为什么他太长的原因(Firefox不会)
作为一种解决方法,我添加了以下行以强制chrome不要等待页面加载时间太长:
driver.set_page_load_timeout(7)
执行现在需要几秒钟:
Start: 2019-06-20 13:23:24.746351
TIMEOUT - Element not found
Diff = 0:00:07.004282
disconnect
Diff = 0:00:07.036196
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.