Hi everyone.
I am using Eclipse with Selenium and Chrome driver.
When I run the script from Eclipse, the script works when I send zip code 95678.
After zip 95678 is entered, a listbox should be active and "Placer" item should be listed in the listbox.
Issue #1:
If I don't click on eclipse or Chrome browser, I get this error below.
Error found: Expected condition failed: waiting for element found by By.id: cboGroupCounty to be selected (tried for 15 second(s) with 500 MILLISECONDS interval)
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'TRAMY-BLLAP', ip: '10.16.28.103',
os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_144'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8), userDataDir=C:\Users\tramy\AppData\Local\Temp\scoped_dir10984_31192}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=59.0.3071.115, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: 968aa5921b91b0f8e1a8b9b23d80d3df
Issue #2:
If I click (putting focus back) on eclipse or Chrome browser, I don't get an error and the script selects Placer county.
Do you know how I can put the focus back on Chrome or this page?
// Part of my code looks like below.
public class BrokerTest {
public static void main(String[] args) throws InterruptedException
{
//Navigate to Step2 - Group Info
//Page Object for Group Info
GroupInfoPageObject group = new GroupInfoPageObject(driver);
page.alertme(driver);
group.myGroupName.sendKeys("Group Name");
group.myZip.click();
group.myZip.sendKeys("95678");
try{
WebDriverWait wait = new WebDriverWait(driver, 30);
// Wait until expected condition size of the dropdown increases and becomes more than 1
wait.until((ExpectedCondition<Boolean>) new ExpectedCondition<Boolean>()
{
public Boolean apply(WebDriver driver)
{
Select selectcty = new Select(driver.findElement(By.id("cboGroupCounty")));
return selectcty.getOptions().size()>1;
}
});
//To select the first option
Select selectcty = new Select(driver.findElement(By.id("cboGroupCounty")));
selectcty.selectByVisibleText("Placer");
}catch(Throwable e){
System.out.println("Error found: "+e.getMessage());
}
}
}