Select oSel=
new Select(oCategoryItems);It throws an error message saying,
Element should have been "select" but was "input"
The reason being Ext JS combo box are not just combo boxes, they combination of controls like,
<Input> and <Image> or <em>
<input> and <Select>
You can see the sample combo box object in Naukri.com website, which is attached
So inorder to select these items, first we need to click on the Input object and then select the value.
Following is the code for printing out all the values, you can use whatever function you want after clicking the object.
import
java.util.List;
import
org.openqa.selenium.By;
import
org.openqa.selenium.WebDriver;
import
org.openqa.selenium.WebElement;
import
org.openqa.selenium.firefox.FirefoxDriver;
import
org.openqa.selenium.support.ui.Select;
public
class PrintListBoxValues
{
{
WebDriver driver=
new FirefoxDriver();
driver.get(
"http://www.naukri.com/");
WebElement oCategory=driver.findElement(By.id(
"farea"));
oCategory.click();
WebElement oCategoryItems=driver.findElement(By.id(
"fareaSL"));
Select oSel=
new Select(oCategoryItems);
List<WebElement> oListItems=oSel.getOptions();
{
System.
out.println(oListItems.get(i).getText());
}
}
}
No comments:
Post a Comment