ACTIONCHAINS SELENIUM PYTHON ПРИМЕРЫ

Библиотека Selenium позволяет автоматизировать взаимодействие с веб-страницами, а пакет ActionChains позволяет выполнять сложные перетаскивания и клики на элементах страницы. Вот несколько примеров:

Пример 1:

from selenium.webdriver import ActionChainsfrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as EC driver = webdriver.Chrome()driver.get("https://www.python.org/") elem = driver.find_element_by_link_text("Downloads") # Hover the mouse over the Downloads linkhover = ActionChains(driver).move_to_element(elem)hover.perform() # Wait for the submenu to appearsubmenu = WebDriverWait(driver, 5).until( EC.presence_of_element_located((By.ID, "downloads-menu"))) # Click the link to the latest Python 3 releasesubmenu.find_element_by_link_text("Python 3.10.0").click()

Пример 2:

from selenium import webdriverfrom selenium.webdriver.common.action_chains import ActionChains driver = webdriver.Chrome()driver.get("https://www.selenium.dev/") elem = driver.find_element_by_link_text("Downloads") # Double-click the Downloads linkdouble_click = ActionChains(driver).double_click(elem)double_click.perform() # Move the mouse to the search box and enter a search querysearch_box = driver.find_element_by_name("search")hover = ActionChains(driver).move_to_element(search_box)hover.click().send_keys("Python Selenium").perform()

Пример 3:

from selenium import webdriverfrom selenium.webdriver.common.action_chains import ActionChains driver = webdriver.Chrome()driver.get("https://www.python.org/") elem = driver.find_element_by_link_text("Documentation") # Right-click the Documentation link to open the context menuright_click = ActionChains(driver).context_click(elem)right_click.perform() # Click the first option in the context menuActionChains(driver).send_keys(Keys.ARROW_DOWN).send_keys(Keys.RETURN).perform()

Это только некоторые из возможностей, которые предоставляет ActionChains вместе с библиотекой Selenium.

Python Selenium - Mouse Based Action Chains in Selenium

Python Selenium Tutorial #4 - ActionChains \u0026 Automating Cookie Clicker!

Selenium with Python Tutorial 17-Handle Mouse Actions - Mouse Hover Action

Python Selenium Action Chains Example

ActionChains - Automate browser element actions using selenium python

Move to Element in selenium python -Action Chain in selenium web driver python

pause() ActionChains command using Selenium Python (Selenium Python)

Python Selenium Tutorial #4 - ActionChains Automation

How To Perform Drag and Drop In Selenium Using Python - ActionChains In Selenium

Что мы можем узнать по номеру телефона. Phyton и библиотека phonenumbers помогут нам в этом.

BLGPG-0D006165296E-24-09-19-20

Новые материалы: