Step 1: Here I am trying to automate testing of a webpage that contains list of items. User input item is selected and is deleted. Here, I need to select BR2 and delete that item.
Step 2:In the above code contains class name.So,I am using class name.
List<WebElement> list =driver.find_element_by_class_name("list-item-view");
for(WebElement option : list){
System.out.println(option.getText());
if(option.getText().equals("BR2")) {
option.click();
break;
}
}
<div id="virtual_domains-content">
<div class="columns">
<div class="left-column">
<h2>Virtual Domains</h2>
<div class="search-row">
<div class="box scrolling list-editable">
<div id="virtual_domains-list" class="list-view">
<div id="virtual_domains-list-11" class="list-item-view">
<div class="content"> BR1</div>
</div>
<div id="virtual_domains-list-35" class="list-item-view">
<div class="content"> BR2</div>
</div>
</div>
</div>
Step 2:In the above code contains class name.So,I am using class name.
List<WebElement> list =driver.find_element_by_class_name("list-item-view");
for(WebElement option : list){
System.out.println(option.getText());
if(option.getText().equals("BR2")) {
option.click();
break;
}
}
No comments:
Post a Comment