Python의 Sleeping Selenium WebDriver with Milliseconds
질문:
어떻게 일시 중지할 수 있나요? 다음을 사용하여 밀리초 동안 Selenium WebDriver 실행 Python?
답변:
time.sleep(초) 사용
시간 라이브러리를 사용하여 WebDriver를 잠자기할 수 있습니다. 부동 소수점 수를 전달하여 밀리초 동안 초:
import time time.sleep(0.25) # Sleeps for 250 milliseconds
주의:
단, 특정 조건 없이 time.sleep(secs)을 사용하면 요소 상태를 확인하지 않고 실행을 일시 중단하므로 자동화의 목적이 무산됩니다. .
추천 접근 방식:
time.sleep(초) 대신에 예상_조건과 함께 WebDriverWait를 사용하여 계속하기 전에 요소 상태를 확인하세요. 다음은 일반적으로 사용되는 세 가지 예상_조건입니다.
presence_of_element_location(locator)
요소가 DOM에 관계없이 DOM에 존재하는지 확인합니다. visible.
visibility_of_element_location(locator)
요소가 존재하고 표시되며 높이가 0이 아닌지 확인하고 width.
element_to_be_clickable(locator)
요소가 표시되고, 활성화되고, 활성화되는지 확인합니다. 클릭 가능.
예:
from selenium.webdriver import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC # Wait 10 seconds until the element with the ID "my_element" becomes visible before clicking it WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, "my_element"))) driver.find_element(By.ID, "my_element").click()
참조:
- [WebDriverWait가 예상대로 작동하지 않음]( )
위 내용은 Python에서 Selenium WebDriver를 밀리초 동안 절전 모드로 만들 수 있나요?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

Python은 해석 된 언어이지만 편집 프로세스도 포함됩니다. 1) 파이썬 코드는 먼저 바이트 코드로 컴파일됩니다. 2) 바이트 코드는 Python Virtual Machine에 의해 해석되고 실행됩니다. 3)이 하이브리드 메커니즘은 파이썬이 유연하고 효율적이지만 완전히 편집 된 언어만큼 빠르지는 않습니다.

USEAFORLOOPHENTERATINGOVERASERASERASPECIFICNUMBEROFTIMES; USEAWHILLOOPWHENTINUTIMONDITINISMET.FORLOOPSAREIDEALFORKNOWNSEDINGENCENCENS, WHILEWHILELOOPSSUITSITUATIONS WITHERMINGEDERITERATIONS.

Pythonloopscanleadtoerrors likeinfiniteloops, modifyinglistsdizeration, off-by-by-byerrors, zero-indexingissues, andnestedloopineficiencies.toavoidthese : 1) aing'i

ForloopSareadvantageForkNowniTerations 및 Sequence, OffingSimplicityAndInamicConditionSandunkNowniTitionS 및 ControlOver Terminations를 제공합니다

Pythonusesahybridmodelofilationandlostretation : 1) ThePyThoninterPretreCeterCompileSsourcodeIntOplatform-IndependentBecode.

Pythonisbothingretedandcompiled.1) 1) it 'scompiledtobytecodeforportabilityacrossplatforms.2) thebytecodeisthentenningreted, withfordiNamictyTeNgreted, WhithItmayBowerShiledlanguges.

forloopsareusedwhendumberofitessiskNowninadvance, whilewhiloopsareusedwhentheationsdepernationsorarrays.2) whiloopsureatableforscenarioScontiLaspecOndCond


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

맨티스BT
Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

ZendStudio 13.5.1 맥
강력한 PHP 통합 개발 환경

PhpStorm 맥 버전
최신(2018.2.1) 전문 PHP 통합 개발 도구