Following are the few methods to select a value in drop down. 1 ) new Select(driver.findElement(By.id("ele_ID"))).selectByVisibleText("xxxxx"); 2) WebElement select = driver.findElement(By.id("ELE_ID")); Listoptions = select.findElements(By.tagName("option")); for (WebElement option : options) { if("expected_string".equalsIgnoreCase(option.getText())) option.click(); }
For handling Dialog boxes which are not web based, Then Autoit is the best Tool to handle this These are the following code should written in Selenium Selenium Code: try { String[] commands = new String[] {}; commands = new String[] { "Path" }; // location of Autoit EXE file Runtime.getRuntime().exec(commands); } catch (IOException e) { } Autoit code: if WinWaitActive("File Upload") Then ;MsgBox(2,"window found","Found the window") WinActivate("File upload") Send("!n") Sleep(5000) Send("File path") SEND("{ENTER}") ;location of the file you want to a to the form and submit ;Send("!O") Else MsgBox(1,"TimeOut","Timed out") EndIf Here we need to create a Exe file for the Autoit script and that path should be mentioned in selenium code.
Comments
Post a Comment