Hi,
Before raising thishere, i have read all the related topics and tried all the possible options. But i couldnt able to sleect the value from the dropdwon
I can able to click the dropdown but not the selection of a value from it
The HTML SELECT element is the host that transfers the selected OPTIONS( )when the page is submitted to the server. However, the element above the SELECT element is the element you need to automate and interact with:
From there, remove the index of the XPATH, like this:
//*[@id='survery_type']/li/option
/**
Then, create a new test object and make that XPATH as your locator
**/
The purpose of removing that index is when the script runs and those three options are already visible in your website your code will automatically collect those three items.
How? refer to the code below. . .
//import webelement
import org.openqa.selenium.WebElement
WebUI.click(findTestObject("Click_your_dropDown"))
WebUI.delay(2)
/**
This is the code that will collect those three items once it is already visible on your website. Since, you're getting their common locator "//*[@id='survery_type']/li/option" all of them will be stored in your list as an array.
**/
//create a list
java.util.List<WebElement> dropDownItems = WebUiCommonHelper.findWebElements(findTestObject("The_testobject_I_mention_to_create"), 30)
//to check if it gets all the items.
println dropDownItems.text.toString()
//to execute an event, just use their index. . . .
dropDownItems[0].click()
/**
Where:
[0] = Survey
[1] = Poll
[2] = Recurring survey
**/