두 사이트에서 작업 중이며 스레드 라이브러리를 사용하여 다른 Selenium 드라이버에서 한 드라이버의 절전 시간을 사용하려고 시도했지만 지금까지는 그렇지 않습니다. 내가 생각했던 방식대로 작동하지 않는 것 같아. 그래서, 나는 내 문제에 대한 설명, 제안 및 수정을 찾고 있습니다.Pythton3의 다른 Selenium 드라이버 (쓰레딩 포함)에서 sleep 시간을 사용하는 방법
이것은 예제 코드입니다.
import threading
from selenium import webdriver
import time
def go_Yahoo():
driver = webdriver.Firefox()
driver.get('https://www.yahoo.com/')
time.sleep(10)
driver.find_element_by_xpath('//*[@id="uh-search-box"]').clear()
time.sleep(1)
driver.find_element_by_xpath('//*[@id="uh-search-box"]').send_keys('facebook')
time.sleep(7)
driver.find_element_by_xpath('//*[@id="uh-search-button"]').click()
def go_Bing():
driver = webdriver.Firefox()
driver.get('https://www.bing.com/')
time.sleep(5)
driver.find_element_by_xpath('//*[@id="sb_form_q"]').clear()
time.sleep(3)
driver.find_element_by_xpath('//*[@id="sb_form_q"]').send_keys('facebook')
time.sleep(1)
driver.find_element_by_xpath('//*[@id="sb_form_go"]').click()
t1 = threading.Thread(target=go_Yahoo())
t2 = threading.Thread(target=go_Bing())
t1.start()
t2.start()
t1.join()
t2.join()
그래서 나는 'go_Yahoo()은'자고있는 동안, 'go_Bing()가'킥 것입니다. 그러나, 나는 어떻게 든 잘못이라고 생각했다. 왜 그리고 어떻게 해결할 수 있는지 알고 싶습니다.
Thx.