How to handle drop down having SPAN Tags. Please help me.

+1 vote
Hi Team,

I have to handle dropdown contains span tags. I have written the code for input & select tags but it's not working.

I am reading the status (Reject) from excel and trying to choose the same value in a dropdown. but it's not selecting.

Please help.

Regards,

Basha.
May 27 in Selenium by anonymous
• 130 points
357 views
Hey, could you please post the code snippet that you have used and also the error that you are getting?

1 answer to this question.

+1 vote

Hi can u try this once.

Select select = new Select(driver.findElement(By.xpath("//path_to_drop_down")));
select.deselectAll();
select.selectByVisibleText("Value1");
or 
List<WebElement> webElements1 = driver.findElements(By.id("id"));

for(WebElement webElement1 : webElements1) {             

 if( webElement1.getAttribute("name").equals("UrText"))

 {           
    WebElement web1 = webElement1.findElement(By.className("selectboxit-text"));

     JavascriptExecutor js = (JavascriptExecutor)driver;
    js.executeScript("arguments[0].click();", web1);       
 }
}
answered Jun 3 by Sri
• 2,970 points

Related Questions In Selenium

+1 vote
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,520 points
4,495 views
0 votes
2 answers

Can anyone help me that how to run Selenium WebDriver test cases in Chrome?

You first need to download chrome driver ...READ MORE

answered Aug 26, 2019 in Selenium by Abha
• 27,930 points
758 views
0 votes
1 answer

How to choose from a drop-down in Selenium 2?

You can probably use the 'Select' class ...READ MORE

answered Apr 24, 2018 in Selenium by king_kenny
• 3,710 points
366 views
0 votes
1 answer
0 votes
1 answer
0 votes
2 answers

How to scroll the Page up or down in Selenium WebDriver? (using java)

JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript("window.scrollBy(0,555)", ""); or Action classes ...READ MORE

answered Sep 5 in Selenium by Sri
• 2,970 points
13,517 views
0 votes
3 answers

How to scroll down a webpage in selenium using Java?

JavascriptExecutor js = ((JavascriptExecutor) driver); js.executeScript("window.scrollTo(0, document.body.scrollHeight)"); or js.executeScript("arguments[0].scrollIntoView(true);", ...READ MORE

answered Sep 3 in Selenium by Sri
• 2,970 points
25,553 views