シナリオ:古い月と新しい月を比較し、両者が等しくない場合は、新しい月のレポートをダウンロードします。ここ ドロップダウンのオプションがWebdriverによって読み取られない
は、サイトのリンクです: http://www.depreportingservices.state.pa.us/ReportServer/Pages/ReportViewer.aspx?%2fOil_Gas%2fOil_Gas_Well_Historical_Production_Reportそれはすべての読み込み、および2016年1月とダウンロードが報告し、直接、11月にスキップの代わりに、12月のレポートをダウンロード読み込みすべてのオプションを無視します。 2015年10月
以下コードです:
WebElement selectElement = driver.findElement(By.id("ReportViewerControl_ctl04_ctl03_ddValue"));
//Getting the count of the values in the drop down list
Select listBox = new Select(selectElement);
int size1 = listBox.getOptions().size();
//prints the size to the console
System.out.println("Total no. of months in the drop down is:"+ size1);
System.out.println("The old month is: " + oldMonth);
//String newMonth ="";
//listBox.selectByIndex(3);
String newMonth ;
for (int i = 1; i < size1; i++) {
WebElement mSelectElement = driver.findElement(By.xpath(".//*[@id='ReportViewerControl_ctl04_ctl03_ddValue']"));
List<WebElement> optionsList = mSelectElement.findElements(By.tagName("option"));
WebElement element = optionsList.get(i);
newMonth = element.getText();
//Message that prints the new month
System.out.println("The new month is:"+newMonth);
/*Condition to check if the New month is equal to Old month, if it is not equal then proceeds
* to download that particular month data or else breaks the loop
*/
if (!oldMonth.equals("All") & !newMonth.equals("All")) {
if (oldMonth.equals(newMonth)) {
System.out.println("No new months are available to download");
Wait(10000);
driver.close();
break;
}//else if (i==1 || (oldMonth.equals(newMonth))) {
//else if (i==1 & !(oldMonth.equals(newMonth))) {
else if (!(oldMonth.equals(newMonth))) {
download report
}
それはforループバックに
ここから先月と新月を比較しているか確認してください –
私は右に静的に言った1つのtxtファイルを編集する= octは2015年の月、txtファイルからは文字列を比較します。 newmonthは選択の「すべて」から始まります。すべて!= oct 2015、Jan!= oct 2015など... – user2762008