我想在可见/加载图像后单击一个按钮, 该测试需要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
答案 0 :(得分:1)
有人告诉我我正在测试的网站与Hidden Iframe(使用Javascript进行Comet编程)一起工作,动态Web应用程序的一项基本技术是使用隐藏的iframe HTML元素(内嵌框架,允许网站嵌入)一个HTML文档放在另一个文档中)。这个不可见的iframe以块状块的形式发送,它隐式地将其声明为无限长(有时称为“永远帧”)
我检查了“开发工具” =>网络: 就像脚本永远不会停止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