Find out dynamic id value using selenium webdriver
//Find out the dynamic ids using name elements
List<WebElement> element = driver.findElements(By.name("Kalyan"))
//Print out all the ids
System.out.println(“Print out the list of id’s is “ + name);
//Store id value in the array
data.add(name);
}
For (int j = 0; j<data.size(); j++){
//Store each value from the array in the obj
String Obj = data.get(j);
// inner buttons like inside the box or element using xpath
String insidebutton = “//div[@id=”+Obj+”]/div/div/div[2]/div[2]/p”;
System.out.println(“Print out the current button of value using id is ” + insidebutton);
// BoxName element using xpath
String BoxName = “//div[@id=”+Obj+”]/div/div/div[2]/div[2]/p”;
System.out.println(“Print out the current cust of value using id is ” + BoxName);
String CusName = driver.findElement(By.Xpath(BoxName).getText();
System.out.println(“Print out the current cust Name using id value is” + CusName);
//Tap on Customer Name or Tile using xpath
String ButtonClick = “//div[@id=”+Obj+”]/div/div/div[2]/div[2]/p”;
System.out.println(“Print out the current cust Tile using id value is” + CusName);
If (CusName.equalsIgnoreCase(“Kalyan Kumar”)[
//Tap on customer name or tile
driver.findElement(By.Xpath(ButtonClick).click();
System.out.println(“Tap on current customer tile compare with kalyan kumar” + ButtonClick);
//Tap on call button
driver.findElement(By.Xpath(insidebutton).click();
System.out.println(“Tap on on current customer call button compare with kalyan kumar ” + insidebutton);
Thread.Sleep(10000);
Break;
}
}
List<WebElement> element = driver.findElements(By.name("Kalyan"))
//Print out all the elements
System.out.println(“Print out the list of Element value is ” + element);
//Store the value of element size
int value = element.size();
//Print out the value of element size
System.out.println(“Print out the list of Element Names is ” + value);
//Create array here
ArrayList <String> data = new ArrayList <String>();
//Get dynamic id values using above elements
For(WebElement element: element){
String name = element.getAttribute(“id”);
System.out.println(“Print out the list of Element value is ” + element);
//Store the value of element size
int value = element.size();
//Print out the value of element size
System.out.println(“Print out the list of Element Names is ” + value);
//Create array here
ArrayList <String> data = new ArrayList <String>();
//Get dynamic id values using above elements
For(WebElement element: element){
String name = element.getAttribute(“id”);
//Print out all the ids
System.out.println(“Print out the list of id’s is “ + name);
//Store id value in the array
data.add(name);
}
For (int j = 0; j<data.size(); j++){
//Store each value from the array in the obj
String Obj = data.get(j);
// inner buttons like inside the box or element using xpath
String insidebutton = “//div[@id=”+Obj+”]/div/div/div[2]/div[2]/p”;
System.out.println(“Print out the current button of value using id is ” + insidebutton);
// BoxName element using xpath
String BoxName = “//div[@id=”+Obj+”]/div/div/div[2]/div[2]/p”;
System.out.println(“Print out the current cust of value using id is ” + BoxName);
String CusName = driver.findElement(By.Xpath(BoxName).getText();
System.out.println(“Print out the current cust Name using id value is” + CusName);
//Tap on Customer Name or Tile using xpath
String ButtonClick = “//div[@id=”+Obj+”]/div/div/div[2]/div[2]/p”;
System.out.println(“Print out the current cust Tile using id value is” + CusName);
If (CusName.equalsIgnoreCase(“Kalyan Kumar”)[
//Tap on customer name or tile
driver.findElement(By.Xpath(ButtonClick).click();
System.out.println(“Tap on current customer tile compare with kalyan kumar” + ButtonClick);
//Tap on call button
driver.findElement(By.Xpath(insidebutton).click();
System.out.println(“Tap on on current customer call button compare with kalyan kumar ” + insidebutton);
Thread.Sleep(10000);
Break;
}
}
Comments
Post a Comment