Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Selenim learning: setting element wait

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Show wait

Show wait for Webdriver to continue execution when a condition is established, otherwise a timeout exception is thrown when the maximum length of time is reached (TimeoutException)

From selenium import webdriverfrom time import * from selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as EC# renamed expected_conditions to ECdriver = webdriver.Chrome () url = 'http://www.baidu.com'driver.get(url)element = WebDriverWait (driver,5,0.5). Until (EC.presence_of_element_located ((By.ID,'kw')) element.send_keys (' selenium') sleep (5) driver.quit ()

The WebDriverWait class is a wait method provided by WebDriver. Within the set time, by default, whether the current page element exists is detected by default, and an exception is thrown if it cannot be detected beyond the setting time.

2.sleep method

The sleep () method is provided by the time module of python

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report