Python Forum
Posting value from excel to Form (Python+Selenium) - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Posting value from excel to Form (Python+Selenium) (/thread-24230.html)



Posting value from excel to Form (Python+Selenium) - revanth - Feb-05-2020

import selenium
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
pass_email = df['Email'].tolist()
type(pass_email)

#using chrome to access web
driver = webdriver.Chrome("path\\chromedriver.exe")
#open the specific page 
driver.get("url")
#find the fields where the value needs to be entered
for value in pass_email:
    try:
        text_input = driver.find_element_by_xpath("//input[contains(@id, 'f_f2ce5e85a5f51997dfcb1f8e645a3c2d')]")
        text_input.clear()
        text_input.send_keys(value)
        time.sleep(2)
        sub_btn = driver.find_element_by_xpath("//input[contains(@id, 'btnSubmit')]")
        sub_btn.click()
        time.sleep(2)
    except NoSuchElementException:
            continue
I have tried above code to pull the values from list and post it in a form and submit. However, it's getting stopped after first iteration.

Thank you in advance.