import pandas as pd
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
df = pd.read_csv('testfile.csv')
details_lst = []
for column in df.columns:
details_lst.append(df[column][0])
driver = webdriver.Chrome()
driver.get('xxxxxxx')
driver.find_element(By.ID, "ctl00_ctl00_phM_phB_Username").send_keys('xxxxx')
driver.find_element(By.ID, "ctl00_ctl00_phM_phB_Password").send_keys('xxxxxx')
driver.find_element(By.ID, "ctl00_ctl00_phM_phB_LoginButton").click()
driver.find_element(By.LINK_TEXT, "Administration").click()
driver.find_element(By.ID, "ctl00_ctl00_phM_phB_UserAdministrationUserControl_CreateNewUserButton").click()
driver.find_element(By.ID, "ctl00_ctl00_phM_phB_txtFirstName").send_keys(df['firstname'][0])
driver.find_element(By.ID, "ctl00_ctl00_phM_phB_txtLastName").send_keys(df['lastname'][0])
driver.find_element(By.ID, "ctl00_ctl00_phM_phB_txtEmail").send_keys(df['username'][0])
driver.find_element(By.ID, "ctl00_ctl00_phM_phB_txtNotificationEmail").send_keys(df['email'][0])
driver.find_element(By.ID, "ctl00_ctl00_phM_phB_txtVerifyNotificationEmail").send_keys(df['email'][0])
driver.find_element(By.ID, "ctl00_ctl00_phM_phB_txtPhone").send_keys(df['phone'][0])
driver.find_element(By.ID, "btnNext").click()
time.sleep(1)
driver.find_element(By.ID, "chkOrderProducts").click()
time.sleep(1)
driver.find_element(By.ID, "ctl00_ctl00_phM_phB_AccountNumbersList1_lstAvailableAcctNumbers").click()
time.sleep(1)
driver.find_element(By.ID, "ctl00_ctl00_phM_phB_AccountNumbersList1_lstAvailableAcctNumbers").send_keys(Keys.ARROW_UP)
driver.find_element(By.ID, "ctl00_ctl00_phM_phB_AccountNumbersList1_lstAvailableAcctNumbers").send_keys(Keys.TAB)
driver.find_element(By.ID, "ctl00_ctl00_phM_phB_AccountNumbersList1_btnAddAccount").send_keys(Keys.SPACE)
字符串
我知道代码是有点草率,但它得到的工作完成的网站即时通讯使用。我可以很好地运行我的csv的第一行。
我所做的是登录到一个供应商的网站-和im输入用户数据从csv到网站使用键盘快捷键导航。该脚本可以工作,但它只通过第一行-我希望它通过所有的行。看来我需要写一个for循环来遍历行,直到有一个空单元格?
https://imgur.com/HVBHnVO
我能够成功地运行第2行--但我不知道如何迭代到下一行。
我能够运行通过我的csv的第一行,帐户创建得很好。我有我的脚本设置,所以它准备输入下一行-我只是不明白写必要的循环迭代到下一行-任何帮助都表示赞赏,我一直在打字了几个小时试图弄清楚这一点-我有90%-只是需要一些帮助。
1条答案
按热度按时间daupos2t1#
你可以循环使用df。
字符串