I wonder if it is possible to use an index to increase the range of the xpath of a given sheet to fill a given sheet using Java and Selenium
I'm working with a 3 x 3 matrix-sheet and i want to insert data to different columns:
The XPATH of the first box and first column is this:
//*[@id="grid"]/table/tbody/tr[3]/td[3]/input
The XPATH of the second box and first column is this:
//*[@id="grid"]/table/tbody/tr[4]/td[3]/input
The XPATH of the third box and first column is this:
//*[@id="grid"]/table/tbody/tr[5]/td[3]/input
The XPATH of the fourth box and first column is this:
//*[@id="grid"]/table/tbody/tr[6]/td[3]/input
The XPATH of the fifth box and first column is this:
//*[@id="grid"]/table/tbody/tr[7]/td[3]/input
So, the pattern says that "tr" is the box number of each column "td"
Take a look at this picture (i cannot upload images yet):
The third column has these Xpath:
The XPATH of the first box and third column is this:
//*[@id="grid"]/table/tbody/tr[3]/td[5]/input
The XPATH of the second box and third column is this:
//*[@id="grid"]/table/tbody/tr[4]/td[5]/input
The XPATH of the third box and third column is this:
//*[@id="grid"]/table/tbody/tr[4]/td[5]/input
The XPATH of the fourth box and third column is this:
//*[@id="grid"]/table/tbody/tr[4]/td[5]/input
The XPATH of the fifth box and third column is this:
//*[@id="grid"]/table/tbody/tr[4]/td[5]/input
Take a look at this picture:
My question is how can i post data from a data-set and paste it in the different boxes? How can i manipulate the xpath?
I mean, i want to paste these values:
[{1,2},{3,4},{90,90},{143,234},{09,89}]
Expected result:
[1 | |2 ]
[3 | |4 ]
[90 | |90 ]
[143| |243]
[09 | |89 ]
Is it possible to put an index on the xpath?:
//*[@id="grid"]/table/tbody/tr[i]/td[j]/input
This is how i post data but it is harcoded:
driver.findElement(By.xpath("//*[@id=\"grid\"]/table/tbody/tr[3]/td[3]/input")).sendKeys("1");
driver.findElement(By.xpath("//*[@id=\"grid\"]/table/tbody/tr[4]/td[3]/input")).sendKeys("3");
driver.findElement(By.xpath("//*[@id=\"grid\"]/table/tbody/tr[5]/td[3]/input")).sendKeys("90");
driver.findElement(By.xpath("//*[@id=\"grid\"]/table/tbody/tr[6]/td[3]/input")).sendKeys("143");
driver.findElement(By.xpath("//*[@id=\"grid\"]/table/tbody/tr[7]/td[3]/input")).sendKeys("09");
driver.findElement(By.xpath("//*[@id=\"grid\"]/table/tbody/tr[3]/td[5]/input")).sendKeys("2");
driver.findElement(By.xpath("//*[@id=\"grid\"]/table/tbody/tr[4]/td[3]/input")).sendKeys("4");
driver.findElement(By.xpath("//*[@id=\"grid\"]/table/tbody/tr[5]/td[5]/input")).sendKeys("90");
driver.findElement(By.xpath("//*[@id=\"grid\"]/table/tbody/tr[6]/td[3]/input")).sendKeys("243");
driver.findElement(By.xpath("//*[@id=\"grid\"]/table/tbody/tr[7]/td[5]/input")).sendKeys("89");
How can i post the data by using the collection and indexes on the xpath?