Apr-25-2020, 06:20 PM
HELLO, i just learned python and this is my first project.
everything is working fine except looping part. if amount is 10 and i have 2 automation site functions. so as loop starts, loop count 1 and site function should be 1 and as as loop count 2 so site function 2 should start but its not working like that. as the loop starts site 1 function repeating 10 times then it goes to site 2 function, i dont want like this. i want to make it, 1 count = site 1 function, count 2 = site 2 function should work. PLEASE HELP. THANK YOU.
everything is working fine except looping part. if amount is 10 and i have 2 automation site functions. so as loop starts, loop count 1 and site function should be 1 and as as loop count 2 so site function 2 should start but its not working like that. as the loop starts site 1 function repeating 10 times then it goes to site 2 function, i dont want like this. i want to make it, 1 count = site 1 function, count 2 = site 2 function should work. PLEASE HELP. THANK YOU.
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 time
mobile_number = '9199999999'
amount = 10
chrome_options = webdriver.ChromeOptions()
prefs = {"profile.default_content_setting_values.notifications" :
chrome_options.add_experimental_option("prefs",prefs)
browser = webdriver.Chrome(chrome_options=chrome_options)
def decathlon(mobile_number): #SITE 1 FUNCTION
for i in range(amount):
browser.get('https://www.decathlon.in/')
time.sleep(2)
login = browser.find_element_by_class_name('m-0').click()
time.sleep(1)
number = browser.find_element_by_class_name('floating-input').send_keys(mobile_number)
button = browser.find_element_by_class_name('decabutton').click()
time.sleep(2)
#browser.quit()
def shaze(mobile_number): #SITE 2 FUNCTION
for i in range(amount):
browser.get('https://www.shaze.in/customer/account/create/')
time.sleep(2)
number = browser.find_element_by_class_name('mobnumber').send_keys(mobile_number)
time.sleep(1)
otp = browser.find_element_by_class_name('regi-sendotp').click()
time.sleep(2)
#browser.quit()
for i in range(amount): # LOOP for repeating automation
shaze(mobile_number)
decathlon(mobile_number)
