0

When selecting position 200 in a dropdown it takes up to 30 seconds to return it. How can I return the result faster?

@FindBy(xpath = "//*[@id=\"searchCriteria\"]/table/tbody/tr[3]/td[2]/select/option[221]")
private WebElement fast;
ClickControl.click(fast);
PRERNA PAL
  • 381
  • 2
  • 10
Catia
  • 45
  • 5
  • what do you mean by faster call ? – cruisepandey Aug 08 '19 at 10:48
  • Its taking up to 30/40 sec to find the element, I presume the position is to blame (221) I just wanted to know if there is a way for the command to find the element within the dropdown faster. – Catia Aug 08 '19 at 10:50
  • Have you tried with `@FindBy(xpath = "(//*[@id='searchCriteria']/table/tbody/tr[3]/td[2]/select/option)[221]")")`? Can you please share html or url if possible for the so that we can provide more diagnosis report. – supputuri Aug 08 '19 at 12:27
  • Try css instead of xpath – pguardiario Aug 09 '19 at 01:36

1 Answers1

0

Find your dropdown using Select class. Then, you can select the required value within dropdown using different methods like selectByValue, selectByVisibleText or SelectByIndex. This will surely take less time.

Select drpdown = new Select(driver.findElement(By.xpath("xpath_of_your_element")));
drpdown.selectByVisibleText("abc");// selectByValue("123"),selectByIndex(1)
PRERNA PAL
  • 381
  • 2
  • 10