我需要在我的网站中自动化链接。我想在循环的每次迭代中传递一次xpath值。这样我就可以最小化我的编码了 公共课Popup {
import time
import subprocess
import pandas as pd
import xlrd
# at first I try to know how many rows and how many columns I have
workbook = xlrd.open_workbook('myfile.xls')
for sheet in workbook.sheets():
for row in range(sheet.nrows):
for column in range(sheet.ncols):
subprocess.run(["clear"])
print "row::::: ", row
print "column:: ", column
print "value::: ", sheet.cell(row,column).value
time.sleep(5.5) # pause 5.5 seconds
答案 0 :(得分:0)
你能试试吗?
for(int j=2; j<=5; j++) {
driver.findElement(By.xpath("//div[@id='info-list']/div[2]/div/div/div/div/a["+j+"]/i")).click();
}
答案 1 :(得分:0)
嗨Sanchit Khera试试这个:
int i = 0;
//extract the link texts of each link element
for (WebElement e : linkElements)
{
linkTitles[i] = e.getText();
i++;
}
//Test each link
for (String t : linkTitles)
{
// Titles Click
driver.findElement(By.linkText(t)).click();