-1

I have automated to send the numbers from the numbers array one by one to text box as shown below, while the numbers are get it from the array and at the same time how to get the mail id randomly one by one from the email array?

import time

numbers = [2589001,2589002,2589003,2589004,2589005,2589006,2589007,2589008,2589009,2589010] 
email = ["mail1@gmail.com","mail2@gmail.com","mail3@gmail.com","mail4@gmail.com","mail5@gmail.com"] 

def oo() :
    for idx in email :
    
        email_from_list = email[idx%len(email)]
        
#I want to put those email function code here and need to pass this def oo()

c = 0
def vs () :
    for idx, nm in enumerate(numbers) :
        
        #Number Input
        WebDriverWait(browser, 2500).until(EC.presence_of_element_located((By.NAME, "Number"))).send_keys(nw)
        time.sleep(1)
        
        WebDriverWait(browser, 2500).until(EC.presence_of_element_located((By.NAME, "Number"))).send_keys(oo()) #<---- here need to call
        time.sleep(1)
        #I need code here to get email id one by one randomly from array   <--- Fix you wording. You don't actually want them one by one randomly

w = 0     
while w < 50 :
    vs ()
    w += 1
Raaj
  • 3
  • 2

1 Answers1

0

I've read your comment, and what you are describing there is not what you are asking for in the original post/question. What you want is to iterate over the same list of emails (not want to select a random email).

import time

numbers = [2589001,2589002,2589003,2589004,2589005,2589006,2589007,2589008,2589009,2589010] 
email = ["mail1@gmail.com","mail2@gmail.com","mail3@gmail.com","mail4@gmail.com","mail5@gmail.com"] 

c = 0
def vs () :
    for idx, nm in enumerate(numbers) :
        
        #Number Input
        WebDriverWait(browser, 2500).until(EC.presence_of_element_located((By.NAME, "Number"))).send_keys(nw)
        time.sleep(1)
        
        #I need code here to get email id one by one randomly from array   <--- Fix you wording. You don't actually want them one by one randomly
        email_from_list = email[idx%len(email)]
        


w = 0     
while w < 50 :
    vs ()
    w += 1
chitown88
  • 27,527
  • 4
  • 30
  • 59
  • once i print(email_from_list) the email not getting order from array. – Raaj Oct 21 '21 at 13:12
  • what do you mean not getting order? – chitown88 Oct 21 '21 at 13:27
  • Excellent..! this function is working perfect, as what i needed and i just need to change a bit i edited in my main post can you please support me, i need those e-mail function inside the def and need to call the def to the .send_keys(oo()) – Raaj Oct 21 '21 at 18:38
  • make sure to accept the solution if it fit your needs – chitown88 Oct 21 '21 at 19:09
  • its accepted and can you please help me to get the e-mail function from a def and call to the .send_keys(oo()) – Raaj Oct 21 '21 at 19:11
  • can you please fix my request ? – Raaj Oct 22 '21 at 08:46
  • You can't just edit the original post. It defeats the whole purpose of stackoverflow with allowing people to search for solutions to problems. You have new request/quest, so you need to open up a new question. Secondly, the question as phrased will get downvoted and would not get answered. You need to provide code of what you have tried, as stackoverflow is not a code writing service – chitown88 Oct 22 '21 at 08:49