使用powershell selenium获取CSV数据以自动填写表单

使用powershell selenium获取CSV数据以自动填写表单,powershell,selenium,csv,Powershell,Selenium,Csv,好的,我是powershell的新手,正在尝试使用CSV中的数据自动填写表单。我已经成功地创建了一个脚本来自动化它一次,但我需要导入“boltsemployees.csv”,并让它用新数据重复填写同一表单。 我已经为一个条目编写了脚本,但我需要它用第一行数据填写表单,然后从下一行csv数据开始用其他用户信息填写表单 调用csv文件并在有“sendkeys”的地方重复自动填写此表单需要什么代码 #!/bin/bash $workingPath = 'C:\Selenium' #add w

好的,我是powershell的新手,正在尝试使用CSV中的数据自动填写表单。我已经成功地创建了一个脚本来自动化它一次,但我需要导入“boltsemployees.csv”,并让它用新数据重复填写同一表单。 我已经为一个条目编写了脚本,但我需要它用第一行数据填写表单,然后从下一行csv数据开始用其他用户信息填写表单

调用csv文件并在有“sendkeys”的地方重复自动填写此表单需要什么代码

 #!/bin/bash 

$workingPath = 'C:\Selenium'

#add working directory to the environment path - required for ChromeDriver 
if (($env:Path -split ';') -notcontains $workingPath) {
$env:Path += ";$workingPath"
}

# Check the Path environment variable
$env:Path -split ';'

# Import Selenium to PowerShell using the Import-Module cmdlet.
Import-Module "$($workingPath)\WebDriver.dll"

 # Go to bolts web app
 $YourURL = "https://newaccounttest.firstunited.bank/bolts/launchpad/app/#!/desktop" # Website we'll access

$ChromeDriver = New-Object OpenQA.Selenium.Chrome.ChromeDriver

$ChromeDriver.Navigate().GoToURL($YourURL)

# Enter username, password and click login 
Start-Sleep -s 1
Wait-Job $ChromeDriver.FindElementByXPath('/html/body/div/div/ui-view/login/div/md-content/form/div/md-input-container[1]/input').SendKeys('sfreeman')
$ChromeDriver.FindElementByXPath('/html/body/div/div/ui-view/login/div/md-content/form/div/md-input-container[2]/input').SendKeys('Getmoney^7Getmoney^7')
Start-Sleep -s 2
$ChromeDriver.FindElementByXPath('/html/body/div/div/ui-view/login/div/md-content/form/button/span').Click()
Start-Sleep -s 6

# Click Employee channel 
$ChromeDriver.FindElementByXPath('/html/body/div/div/ui-view/desktop/blt-tiles/button[3]').Click()
Start-Sleep -s 10
$ChromeDriver.FindElementByXPath('/html/body/div/ui-view/ui-view/blt-tiles/button[2]').Click()
Start-Sleep -s 5
$ChromeDriver.FindElementByXPath('/html/body/div/ui-view/ui-view/md-fab-speed-dial/md-fab-trigger/button').Click()
$ChromeDriver.FindElementByXPath('/html/body/div/ui-view/ui-view/md-fab-speed-dial/md-fab-actions/div[1]').Click()
 Start-Sleep -s 3

# Enter last name , first name & hit create new applicant
$ChromeDriver.FindElementByXPath('/html/body/div[3]/md-dialog/div[2]/div/form/div[1]/md-input-container[1]/input').SendKeys('freeman')
$ChromeDriver.FindElementByXPath('/html/body/div[3]/md-dialog/div[2]/div/form/div[1]/md-input-container[2]/input').SendKeys('seth')
$ChromeDriver.FindElementByXPath('/html/body/div[3]/md-dialog/div[2]/div/form/div[2]/button').Click()
Start-Sleep -s 4