Monday 23 March 2015

How to search the value in grid and delete the particular record in selenumn web driver

How to search the value in grid and delete the particular record in selenumn web driver

Below is the code to search the particular record in grid through xpath manuplation

Step-1. First you need to divide the xpath in two part, store in two different string object
2.Full xpath like  below
  //*[@id='rup_data_binding_tr_0_search_form_list']/td[2]/p
3.We need to search the 

            String xp1="//*[@id='rup_data_binding_tr_"+i;
            String xp2="_search_form_list']/td[2]/p";
            for (int i=0;i<12;i++)
            {
                WebElement gettext=driver.findElement(By.xpath(xp1.concat(xp2)));
                System.out.println("all agency ="+gettext.getText());
                if (text.equals(gettext.getText()))
                {
                           System.out.println("Deleted Agency ="+gettext.getText());
                           Assert.assertEquals(text,gettext.getText());
                          driver.findElement(By.xpath(xp1.concat("_search_form_list']/td[8]/p/a[2]  
                         /img"))).click();
                         driver.findElement(By.xpath("//*[@id='dvRupConfirmBox']/div[2]  
                         /input[2]")).click();
                          break;
                }
            }

No comments:

Post a Comment