Basic operations in Selenium Python - Part #2
1. Click button using XPATH and selective attributes
# Identify the button using XPath and Attributesdriver.find_element_by_xpath('//*[@name="btnSearch" and @type="submit"]').click()
2. Delay in specific time
import time
....
....
# Delay the execution in 3 seconds as per below code
time.sleep(3)
3. Control using Keyboard character/button and Mouse controls using pyautogui
Reference:
import pyautogui
...
...
#Press TAB key
pyautogui.press('tab')
#Enter input using typewrite option. Example: ADJUSTMENT
pyautogui.typewrite('ADJUSTMENT')
#Press collective buttons using below way as well
pyautogui.press(['tab', 'tab', 'down', 'tab'])
#Press HOTKEYS using below logic. i.e. ALT + F5
pyautogui.press(['alt', 'f5'])
4. Mouse Control using pyautogui
# Getting current mouse position
# X - X axis; Y - Y axis
(x, y) = pyautogui.position()
print(x,y)
# Move back to where the mouse was before click
# For Example: Application Configurator
pyautogui.moveTo(883, 182)
No comments:
Post a Comment