In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the python automated testing selenium core technology waiting conditions, the article is very detailed, has a certain reference value, interested friends must read it!
Mouse and keyboard events in Selenium are encapsulated in the ActionChains class, using the following methods:
ActionChains (driver) .click (btn) .perform ()
Common methods in ActionChains:
Sample website: http://sahitest.com/demo
Example scenario: open the Sahi Tests page, click the "Alert Test" page, click the "Click For Alert" button on the page, pop up a warning box to determine whether there is an alert on the page, switch to the warning box if it exists, and get the warning text information, and then click the OK button in the warning box.
Sample script:
From selenium import webdriverfrom time import sleepfrom selenium.webdriver.support.wait import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ec class TestWaitCondition (object): def setup (self): self.driver = webdriver.Chrome () self.driver.get ("https://sahitest.com/demo/") def test_waitcondition (self): Alert Test self.driver.find_element_by_xpath (" / html/body/) on the # dot page Table/tbody/tr/td [3] / a [1] "). Click () # Mouse click the" Click For Alert "button on the page self.driver.find_element_by_name (" b1 ") .click () wait = WebDriverWait (self.driver 2) # wait and determine whether the warning box exists wait.until (ec.alert_is_present ()) # switch to the alert page alert = self.driver.switch_to.alert # get and print the text in the warning box print (alert.text) # confirm alert.accept () self.driver.quit () in the pop-up warning box
Running result:
These are all the contents of the article "what are the waiting conditions for the core technology of python automated testing selenium". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.