Need to add data to new row on table Java IntelliJ
I don't know if I'm in the correct forum. I work automating web tests but my knowledge of Java is limited. I can create some methods, but usually take already existing methods and use them as templates.
I am currently automating a ticket where there is an existing table on a web page. It has eight rows, each row with a dropdown menu on the left and four columns with empty cells to the right on each row to enter data.
In my case, there are already three rows of data entered before the page comes up. I need to add a fourth row and data.
I select the dropdown menu on the fourth row with this method - public void clickManualAdditionAndSelectOption(String dropdownOption) { act.waitForElementToBeVisible(btnManualAddition); act.doJSclick(btnManualAddition); act.waitForElementToBeVisible(dropdownShowOptionManualAddition); act.doClick(By.xpath("//ul[@class='dropdown-menu show']/li/a[text()='" + (dropdownOption) + "']")); act.waitImplicitly(2);}
Works fine. I need my next method to add data in the fields in that same row - public void enterManualAdditionColorantAndDispense(String allColorants) { String[] lines = allColorants.split("\\|"); for (int i = 2; i <= 5; i++) { act.waitForElementToBeVisible(By.xpath( "//table[@id='formulaAdditions']/tbody/tr/td[" + (i) + "]/input")); act.enterText(By.xpath( "//table[@id='formulaAdditions']/tbody/tr/td[" + (i) + "]/input"), lines[i - 2]); } act.doJSclick(btnDispenseAddition);}
But what ends up happening is that it inputs my data from the JSON file into the first row of the table, rather than into the fourth row where I just selected from the dropdown menu. How do I make it add my data to whatever number line was just added?
请先登录再写评论。
https://stackoverflow.com/ would be a better place for such questions. This forum is for the questions that are related to JetBrains products.