Scenario : I am currently automating a form where I am passing all input from excel. It includes textboxes ,checkboxes datepicker etc. Form includes total 15 checkboxes. Now I want my script to check 1 checkbox which is mentioned in excel. I am using TestNG and Apache POI for it. Here is what I have done to get it :
public void EventCreation1(String EventName, String EventTagLine,String EventOrganization,String City,String State,String Country, String EventCategory ,String EventDescription,String Name,String EmailID,String Contact)
{
driver.get("WEBPAGE URL");
driver.findElement(By.xpath(".//*[@id='eventName']")).sendKeys(EventName);
driver.findElement(By.xpath(".//*[@id='eventTagLine']")).sendKeys(EventTagLine);
driver.findElement(By.xpath(".//*[@id='organizerName']")).sendKeys(EventOrganization);
driver.findElement(By.xpath(".//*[@id='eventCity']")).sendKeys(City);
driver.findElement(By.xpath(".//*[@id='eventState']")).sendKeys(State);
driver.findElement(By.xpath(".//*[@id='eventCountry']")).sendKeys(Country);
//For Category
List<WebElement> Checkbox = driver.findElements(By.xpath("//input[@type='checkbox']")).getAttribute;
for(int i=0; i<Checkbox.size();i++ )
{
WebElement El =Checkbox.get(i);
String id =El.getAttribute("value");
if(id.equals(EventCategory))
{
El.click();
}
}
Here // String EventCategory is the Checkbox option I am passing as parameter from excel.
Could you please help in this what is wrong here?
HTML Tag:
<div class="section colm colm9">
<div class="frm-row">
<div class="section colm colm4">
<div class="option-group">
<label class="option option-blue block">
<input type="checkbox" name="eventType[]" value="TechFest">
<span class="checkbox"></span> TechFest
</label>
<label class="option option-blue block spacer-t10">
<input type="checkbox" name="eventType[]" value="Cultural Fest">
<span class="checkbox"></span> Cultural Fest
</label>
<label class="option option-blue block spacer-t10">
<input type="checkbox" name="eventType[]" value="Management Fest">
<span class="checkbox"></span> Management Fest
</label>
<label class="option option-blue block spacer-t10">
<input type="checkbox" name="eventType[]" value="Sports Fest">
<span class="checkbox"></span> Sports Fest
</label>
<label class="option option-blue block spacer-t10">
<input type="checkbox" name="eventType[]" value="Workshop">
<span class="checkbox"></span> Workshop
</label>
</div><!-- end .option-group section -->
Aucun commentaire:
Enregistrer un commentaire