I am getting error: Element should have been “select” but was “input” using Selenium Webdriver Java

0 votes

When I select the value form dropdown box it is throwing Error message "Element should have been "select" but was "input” is shown when I select the value form drop down box. I have tried with selectByValue() and selectByIndex().

Below is my HTML:

<div class="rcbScroll rcbWidth" style="width: 100%; overflow: auto; height: 40px;">

<ul class="rcbList" style="list-style:none;margin:0;padding:0;zoom:1;">

<li class="rcbItem">TIN</li>

<li class="rcbHovered">SSN</li>

</ul>

</div>

And the java code:

Select select=new Select(driver.findElement(By.xpath(OR.getProperty("SSN"))));

select.selectByValue("SSN");
Jun 27, 2018 in Selenium by Martin
• 4,220 points
4,150 views

how to solve the same in python .i tried 

driver.find_element_by_xpath("//*[text()='Full SCan']/li").click()

and

driver.find_element_by_xpath("//*li[text()='Full Scan']").click()

both aren't working

Hi Riya, instead of using xpath, use className to identify the dropdown item. Following command would help you:

driver.find_element_by_class_name("rcbItem").click();

Hi @riya, try this:

driver.find_element_by_xpath("//li[@name='element_name']/option[text()='Full Scan']").click()

Either use element name or use option with text. Don't use both at once as shown in the above code. 

1 answer to this question.

0 votes

You can Select element by the following method:

driver.findElement(By.xpath(OR.getProperty("SSN")).click();

 and next select the desired drop down in following way :

driver.findElement(By.xpath("//li[text() = 'SSN']")).click();
answered Jun 27, 2018 by Samarpit
• 5,130 points

Related Questions In Selenium

0 votes
1 answer

Java.lang.CharSequence cannot be resolved error while using sendKeys() using Selenium Webdriver

You could try this, myElement .sendKeys(new String[] { ...READ MORE

answered Apr 4, 2018 in Selenium by Johnathon
• 9,080 points
657 views
0 votes
1 answer
0 votes
1 answer

How to get the select options using Selenium WebDriver in Java

Hey there! You should be able to get ...READ MORE

answered Jun 13 in Selenium by Surya
• 970 points
109 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,090 points
591 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
900 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
576 views
0 votes
1 answer

Firefox browser not opening with given URL using Selenium Webdriver with Java

Download the latest selenium jar and replace ...READ MORE

answered Apr 30, 2018 in Selenium by Samarpit
• 5,130 points
2,256 views
0 votes
1 answer

How to get next sibling element using XPath and Selenium for Java?

Below code will help you: Try following-sibling axis : WebElement ...READ MORE

answered May 15, 2018 in Selenium by Samarpit
• 5,130 points
5,538 views