Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- driver.findElement(By.xpath("//input[@accesskey='9']"));
- td style="width: 5%;">
- <input type="checkbox" data-bind="attr: { accesskey: Id }" accesskey="6">
- </td>
- <td style="width: 5%;">
- <input type="checkbox" data-bind="attr: { accesskey: Id }" accesskey="7">
- </td>
- public void portfolioRenewalSearch(String portfolioId) throws Exception {
- try {
- driver.findElement(By.xpath("//input[@accesskey= portfolioId]"))
- .click();
- } catch (AssertionError Ae) {
- Ae.printStackTrace();
- }
- }
- public void portfolioRenewalSearch(String portfolioId) throws Exception {
- try {
- driver.findElement(By.xpath("//input[@accesskey="+portfolioId+"]"))
- .click();
- } catch (AssertionError Ae) {
- Ae.printStackTrace();
- }
- }
- Here is the solution for index variable
- Let's say, you have found 5 elements with same locator and you would like to perform action on each element by providing index number (Here, variable is used for index as "i")
- for(int i=1; i<=5; i++)
- {
- string xPathWithVariable = "(//div[@class='className'])" + "[" + i + "]";
- driver.FindElement(By.XPath(xPathWithVariable)).Click();
- }
- It takes XPath as below
- (//div[@class='className'])[1]
- (//div[@class='className'])[2]
- (//div[@class='className'])[3]
- (//div[@class='className'])[4]
- (//div[@class='className'])[5]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement