Python Selenium - How to give 100 comma separated list values to selenium send keys?



  • sheet1 = client.open_by_url("https://docs.googlesheet")-- using google sheet here
    
    sh = sheet1.worksheet("Sheet1")
    
    dera = gd.get_as_dataframe(sh1,evaluate_formulas = True,skiprows = 0,has_header = True)
    
    del = dera[['id']].dropna()
    
    z = del2['names'].values.tolist()
    
    driver.get("https://google.com/") -- using google.com as example
    
    time.sleep(5)
    
    driver.refresh()
    
    time.sleep(2)
    
    name_button = driver.find_element_by_xpath("//button[text()='NAMES']")
    
    name_button.click()
    
    time.sleep(2)
    
    driver.find_element_by_xpath("//button[text()='Manual']")
    
    time.sleep(2)
    
    driver.find_element_by_xpath("//div[text()='Maximum 5000 Names'] 
    /..//textarea").send_keys(z)
    
    time.sleep(2)
    

    Not able to pass the defined 430 rows of 'z' into send keys.

    Could someone please help me with this.?

    Changed the names of sheet and google chrome due to privacy issues.



  • You should try looping over the list you created. z is a list, and when you don't loop over the list it tries to run only once.

    for value in z:
        driver.find_element_by_xpath("//div[text()='Maximum 5000 Names']/..//textarea").send_keys(value)
    
    time.sleep(2)
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2