-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.py
26 lines (21 loc) · 1.08 KB
/
helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
def simulate_random_user_interactions(driver):
# Simulate scrolling down using JavaScript
scroll_script1 = "window.scrollTo(0, document.body.scrollHeight);"
driver.execute_script(scroll_script1)
time.sleep(2)
scroll_script2 = "window.scrollTo(0, document.body.scrollHeight);"
driver.execute_script(scroll_script2)
time.sleep(2) # Wait for page to load after scroll
# Simulate mouse hover action
element_to_hover_over = driver.find_element(By.XPATH, "//input[@id=\'search-input\']")
ActionChains(driver).move_to_element(element_to_hover_over).perform()
time.sleep(1) # Wait for hover effect to apply
# remove special characters, numbers and spaces
# make string only first alphabet is capital
def format_word(input_string):
import re
clean_and_format_string = lambda s: re.sub(r'[^a-zA-Z]', '', s).capitalize()
return clean_and_format_string(input_string)