Python Forum

Full Version: Selenium to pick data from excel and enter into backend
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

i have created a script that would enter enter data into backend but all the values are pre defined in it...all i want is that script should pick data from excel and enter into system.

from selenium import webdriver
from selenium.webdriver.common import keys
from selenium.webdriver.support.ui import Select


driver = webdriver.Chrome("./chromedriver")
driver.get('http://newprojects.99acres.com/acd_99.php/mainpage/login')
email = driver.find_element_by_xpath("/html/body/form/table/tbody/tr/td/table/tbody/tr[2]/td[2]/input")
email.send_keys("USERNAME DELETED")

password = driver.find_element_by_xpath("/html/body/form/table/tbody/tr/td/table/tbody/tr[3]/td[2]/input")
password.send_keys("PASSWORD DELETED")

l_button = driver.find_element_by_xpath("/html/body/form/table/tbody/tr/td/table/tbody/tr[4]/td/input")
l_button.click()

l_button2 = driver.find_element_by_xpath("/html/body/table[2]/tbody/tr[3]/td[1]/table/tbody/tr[9]/td/a")
l_button2.click()

radio_button = driver.find_element_by_xpath('//*[@id="projlistview_frm"]/table/tbody/tr[1]/td[2]/input')
radio_button.click()

XID_number = driver.find_element_by_xpath('//*[@id="projlistview_frm"]/table/tbody/tr[1]/td[3]/input')
XID_number.send_keys("279469")

radio_sbmit = driver.find_element_by_xpath('//*[@id="projlistview_frm"]/table/tbody/tr[6]/td/input')
radio_sbmit.click()

carpet_area = driver.find_element_by_xpath('//*[@id="1CARPET_AREA"]')
carpet_area.send_keys("252")

square_meter1 = Select(driver.find_element_by_id('1UNIT'))
square_meter1.select_by_value('sq m')

BHK = Select(driver.find_element_by_id("1BEDROOM"))
BHK.select_by_value('3')

Area_submit = driver.find_element_by_xpath('//*[@id="addition"]')
Area_submit.click()

carpet_area = driver.find_element_by_xpath('//*[@id="2CARPET_AREA"]')
carpet_area.send_keys("343")

square_meter2 = Select(driver.find_element_by_id('2UNIT'))
square_meter2.select_by_value('sq m')

BHK = Select(driver.find_element_by_id("2BEDROOM"))
BHK.select_by_value('3')

Area_final = driver.find_element_by_xpath('//*[@id="frm"]/table[3]/tbody/tr/td/input[5]')
Area_final.click()
Fields i want to pick from excel are XID_number, carpet_area, square_meter1, BHK

now i want to create a loop so that it should pick until all fields are entered and then move to next project id which is XID
Output:
[output]
[/output]
you can see my attached file of excel structure