'Python Selenium webDrvierWati not useful in multiple thread
I am selenium rookie.
I have a question.
I using threads simulate 10 users
Sometime the first chromedriver (thread No.1)
But second chromedriver (thread 2,3...10) click no yet
Other chromedriver was affected by the first page
Report an error
Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="btn"]/div/div[2]/div[1]/div[6]/div"}
Other chromedrivers that have not clicked button 1 went directly to this line
WebDriverWait(driver,30,1).until(EC.visibility_of_element_located((By.XPATH, '//*[@id="btn"]/div/div[2]/div[1]/div[6]/div')))
so make it timeOutReport
How can fix it.
English is not my native language. so I didn't explain clearly enough I’m awfully sorry.
from datetime import datetime
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
import threading
def selenium_mult():
chrome_options = Options()
chrome_options.add_argument("--headless")
ser=Service('./chromedriver')
driver = webdriver.Chrome(service = ser,options=chrome_options)
driver.set_window_size(540,480)
driver.get('https:/website')
WebDriverWait(driver,10,1).until(EC.visibility_of_element_located((By.XPATH, '//*[@id="btn"]/div/div[3]/button[1]')))
driver.find_element(By.XPATH, '//*[@id="btn"]/div/div[3]/button[1]').click() #click button 1
Ftime = datetime.now()
WebDriverWait(driver,30,1).until(EC.visibility_of_element_located((By.XPATH, '//*[@id="btn"]/div/div[2]/div[1]/div[6]/div')))
driver.find_element(By.XPATH, '//*[@id="btn"]/div/div[2]/div[1]/div[6]/div').click() #click button 2
if __name__ == '__main__':
for i in range(10):
t = threading.Thread(target=selenium_mult)
t.start()
I found that the part of clicking the button is not working I try to insert print("click") between webDriverWait and click It response 10 times for me but some webdriver not work
Solution 1:[1]
I found that the part of clicking the button is not working I try to insert print("click") between webDriverWait and click It response 10 times for me but some webdriver not work
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Lou14 |
