Python Forum
not abel to run selenium automation one by one in loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
not abel to run selenium automation one by one in loop
#1
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.

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)
Reply


Messages In This Thread
not abel to run selenium automation one by one in loop - by DevilzKingz - Apr-25-2020, 06:20 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Selenium Chromedriver Automation Help lessthanthree 1 2,172 May-05-2020, 11:03 PM
Last Post: Larz60+
  Error in Selenium: CRITICAL:root:Selenium module is not installed...Exiting program. AcszE 1 3,661 Nov-03-2017, 08:41 PM
Last Post: metulburr
  Python Selenium Document Lookup and Download Automation Error - Target Machine active Guttmann 4 5,253 Apr-18-2017, 12:13 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020