11import random
22import string
33import time
4+
45from selenium import webdriver
56from selenium .webdriver .common .by import By
6- from selenium .webdriver .support .ui import WebDriverWait
77from selenium .webdriver .support import expected_conditions as EC
8+ from selenium .webdriver .support .ui import WebDriverWait
9+
810
911def main ():
1012 options = webdriver .ChromeOptions ()
11- options .add_argument (' --headless' )
12- options .add_argument (' --no-sandbox' )
13- options .add_argument (' --disable-dev-shm-usage' )
13+ options .add_argument (" --headless" )
14+ options .add_argument (" --no-sandbox" )
15+ options .add_argument (" --disable-dev-shm-usage" )
1416
1517 driver = webdriver .Chrome (options = options )
1618
1719 try :
1820 # Generate random user credentials
19- random_suffix = '' .join (random .choices (string .ascii_lowercase + string .digits , k = 8 ))
21+ random_suffix = "" .join (
22+ random .choices (string .ascii_lowercase + string .digits , k = 8 )
23+ )
2024 email = f"testuser_{ random_suffix } @example.com"
2125 password = "securepassword123"
2226 name = "Test User"
@@ -26,14 +30,20 @@ def main():
2630
2731 # Wait for the "Don't have an account? Sign Up" button to be clickable
2832 signup_button = WebDriverWait (driver , 30 ).until (
29- EC .element_to_be_clickable ((By .XPATH , "//*[contains(text(), 'Don\\ 't have an account? Sign Up')]" ))
33+ EC .element_to_be_clickable (
34+ (By .XPATH , "//*[contains(text(), 'Don\\ 't have an account? Sign Up')]" )
35+ )
3036 )
3137 signup_button .click ()
3238
3339 # Fill in the signup form
34- WebDriverWait (driver , 10 ).until (EC .presence_of_element_located ((By .XPATH , "//*[@placeholder='Name']" ))).send_keys (name )
40+ WebDriverWait (driver , 10 ).until (
41+ EC .presence_of_element_located ((By .XPATH , "//*[@placeholder='Name']" ))
42+ ).send_keys (name )
3543 driver .find_element (By .XPATH , "//*[@placeholder='Email']" ).send_keys (email )
36- driver .find_element (By .XPATH , "//*[@placeholder='Password']" ).send_keys (password )
44+ driver .find_element (By .XPATH , "//*[@placeholder='Password']" ).send_keys (
45+ password
46+ )
3747
3848 # Submit the form
3949 # It's better to wait for the element to be clickable
@@ -53,5 +63,6 @@ def main():
5363 finally :
5464 driver .quit ()
5565
66+
5667if __name__ == "__main__" :
5768 main ()
0 commit comments