Skip to content

Instantly share code, notes, and snippets.

@seleniumgists
Created December 6, 2018 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seleniumgists/815642f5751e0338fb14a2997c0968a5 to your computer and use it in GitHub Desktop.
Save seleniumgists/815642f5751e0338fb14a2997c0968a5 to your computer and use it in GitHub Desktop.
generated automatically from #selenium on seleniumhq slack
while(!directoryEmpty) {
String dirPath = "C://YEAR_reports";
File dir = new File(dirPath);
String[] files = dir.list();
if (files.length == 0) {
System.out.println("The directory is empty");
directoryEmpty = true;
} else {
for (String aFile : files) {
System.out.println(aFile);
}
}
//Strip away file extension
String companyName = files[0].replaceFirst(".xml$", "");
WebElement DropdownValueBeforeSelect = driver.findElement(By.tagName("option"));
String CurrentDropDownSelections = DropdownValueBeforeSelect.getText();
System.out.println(CurrentDropDownSelections);
WebElement SaveSelectedFile = driver.findElement(By.name("saveButton"));
SaveSelectedFile.click();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
// CloseTab, button may be out of visible area, just send Enter.
WebElement CloseTab = driver.findElement(By.name("closeButton"));
CloseTab.sendKeys(Keys.ENTER);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment