![](/img/trans.png)
[英]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.