我有一个方案,从最近的数字中取最大值,然后用该数字进行匹配。如果匹配,则将执行单击操作。所有条件都将其放入for循环中。
public static int insertBeforeAfterMethod(int i, String event, String shotType, WindowsDriver < WebElement > mainEntrySession) {
for(int cellIndex = 14;cellIndex < pbp_insert_grid_cells.size();cellIndex+=17) //
{
System.out.println(pbp_insert_grid_cells.size());
rowSequenceNo = pbp_insert_grid_cells.get(cellIndex).getText();
String[] splitvalue=rowSequenceNo.split("\\.");
int guiSequenceNo=Integer.parseInt(splitvalue[0]);
System.out.println("hello gui sequence number....."+guiSequenceNo);
//i==4 here i==3
if ((i%2!=0) && (sequenceNo < guiSequenceNo)) //1.5 <2 insert before
{
System.out.println("hello"+i);
next =guiSequenceNo; //2
System.out.println("next"+next);
break;
}
else if((i%2==0) && (sequenceNo > guiSequenceNo)) //insert after
{
previous=guiSequenceNo;
break;
}
if(next==guiSequenceNo) // 2==rowSequenceNo insert before
{
System.out.println(cellIndex);
WebElement sequenceCellNoInsertBefore = mainEntrySession.findElementByName(pbp_insert_grid_cells.get(cellIndex).getAttribute("Name"));
rowNumber = sequenceCellNoInsertBefore.getAttribute("Name").substring(16);
System.out.println(rowNumber);
if(mainEntrySession.findElementByName(rowNumber).isDisplayed())
{
rowToClick = mainEntrySession.findElementByName("Period " +rowNumber);
rowToClick.click();
action.moveToElement(rowToClick).contextClick().perform();
mainEntrySession.findElementByName("Insert Before").click();
mainEntrySession.findElementByAccessibilityId("6").click();
retValue = getNexti(i, event,shotType,mainEntrySession);
System.out.println("return i "+retValue);
}
}
else if(previous==guiSequenceNo) //insert after
{
WebElement sequenceCellNoInsertAfter = mainEntrySession.findElementByName(pbp_insert_grid_cells.get(cellIndex).getAttribute("Name"));
rowNumber = sequenceCellNoInsertAfter.getAttribute("Name").substring(16);
System.out.println(rowNumber);
if(mainEntrySession.findElementByName(rowNumber).isDisplayed())
{
rowToClick = mainEntrySession.findElementByName("Period " +rowNumber);
rowToClick.click();
action.moveToElement(rowToClick).contextClick().perform();
mainEntrySession.findElementByName("Insert After").click();
mainEntrySession.findElementByAccessibilityId("6").click();
retValue = getNexti(i, event,shotType,mainEntrySession);
System.out.println("return i "+retValue);
}
}
}
return retValue;
}
这里for循环没有增加,它正在退出...不间断地如何立即增大和减小并存储在变量中...?