I have following code -for quikr.com
1. when I am passing valid value for category dropdown (like jobs), I am able to select the dropdown value but immidiately the dropdown value is getting chnaged to default one (All categories)
2. the else part is not working when I want to select random value from dropdown.
Moreover "List<WebElement> list = category.findElements(By.tagName("li"));" is not working I guess, When I am trying to print the list value, its not working, though list size is coming correctly.
--------------------------------------------------------------
public static String selectList(String object, String data){ //div not select
APP_LOGS.debug("Selecting from list");
try {
if(!data.equals(Constants.RANDOM_VALUE))
{
driver.findElement(By.xpath(OR.getProperty(object))).click();
// Thread.sleep(1000);
Actions act = new Actions(driver);
Thread.sleep(2000);
act.moveToElement(driver.findElement(By.linkText(data))).click().build().perform();
Thread.sleep(1000);
}else {
driver.findElement(By.xpath(OR.getProperty(object))).click();
WebElement category = driver.findElement(By.xpath(OR.getProperty(object)));
List<WebElement> list = category.findElements(By.tagName("li"));
Random r = new Random();
int ind = r.nextInt(list.size());
String myS = list.get(ind).getText();
System.out.println("random "+myS);
Actions act = new Actions(driver);
// act.sendKeys(data).build().perform();
Thread.sleep(2000);
act.moveToElement(driver.findElement(By.linkText(myS))).click().build().perform();
}
return Constants.KEYWORD_PASS;
}catch(Exception e) {
return Constants.KEYWORD_FAIL + " cound not select from list" + e.getMessage();
}
}
Instructor
Ashish Thakur Replied on 13/11/2019
This selects jobs and goes to job page
WebDriver driver = new ChromeDriver();
driver.get("https://quikr.com");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.findElement(By.xpath("//*[@id='searchedCat']")).click();
driver.findElement(By.linkText("Jobs")).click();
I did not get.
Problem is when I select the dropdown values, sometime the selected value persists and sometimes it revert back to default value.
Instructor
Ashish Thakur Replied on 18/11/2019
I am able to select from above code - successfully
Yes the bahavior is not consistent
Problem is when I select the dropdown values, sometime the selected value persists and sometimes it revert back to default value.
Instructor
Ashish Thakur Replied on 19/11/2019
this is a website issue !