-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex.py
More file actions
41 lines (35 loc) · 1.53 KB
/
Copy pathex.py
File metadata and controls
41 lines (35 loc) · 1.53 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import csv
# Load phone numbers from the CSV file
phone_numbers = []
with open('phone.csv', 'r') as file:
reader = csv.DictReader(file)
phone_numbers = [row['number'] for row in reader]
# Initialize WebDriver and WebDriverWait
driver = webdriver.Chrome()
wait = WebDriverWait(driver, 10)
# Iterate through phone numbers (up to 10 attempts)
max_attempts = 10
for i, phone in enumerate(phone_numbers[:max_attempts], 1):
try:
# Input the phone number
wait.until(EC.presence_of_element_located((By.ID, "select_phonenumber_input"))).clear()
wait.until(EC.presence_of_element_located((By.ID, "select_phonenumber_input"))).send_keys(phone)
# Click the action button
wait.until(EC.element_to_be_clickable((By.ID, "popup_mobile_action"))).click()
# Check if the "back" button is displayed
try:
wait.until(EC.presence_of_element_located((By.ID, "add_mobile_back")))
print(f"Phone number {phone} is correct. Test successful.")
break # Exit loop as the correct number was found
except:
print(f"Phone number {phone} is incorrect. Trying the next number.")
except Exception as e:
print(f"Error during attempt {i}: {str(e)}")
else:
print("Tested 10 numbers without success.")
# Close the browser after testing
driver.quit()