2017-11-24 7 views
0

連絡先の詳細のドロップダウンページから「MR」という値を選択できません。Seleniumドロップダウン

ここだが、私はここに作ると思います1つの提案は、あなたのSelect要素とselectByVisibleText()メソッドを使用しないコード

public class MySelenium { 
    public static void main(String[] args) { 

     System.setProperty("webdriver.chrome.driver","C:\\Users\\kunal.bhaskar\\Downloads\\chromedriver.exe"); 
     WebDriver driver = new ChromeDriver(); 
    // Form filling on www.spicejet.com  
     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 
     String baseUrl = "http://www.spicejet.com"; 
     driver.get(baseUrl); 
     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 
     driver.findElement(By.xpath("//*[@id=\"ctl00_mainContent_chk_IndArm\"]")).click(); 
     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 
     WebElement dep = driver.findElement(By.xpath("//*[@id=\"ctl00_mainContent_ddl_originStation1_CTXT\"]")); 
     dep.click(); 
     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 
     dep.sendKeys("Bengaluru"); 
     WebElement arr = driver.findElement(By.xpath("//*[@id=\"ctl00_mainContent_ddl_destinationStation1_CTXT\"]")); 
     arr.click(); 
     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 
     arr.sendKeys("Patna"); 
     WebElement date1 = driver.findElement(By.xpath("//*[@id=\"flightSearchContainer\"]/div[3]/button")); 
     date1.click(); 
     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 
     for (int i = 0; i < 3; i++){ 
      //click the button 
      WebElement arrow = driver.findElement(By.xpath("//*[@id=\"ui-datepicker-div\"]/div[2]/div/a/span")); 
      arrow.click(); 

     } 
     WebElement arr1 = driver.findElement(By.xpath("//*[@id=\"ui-datepicker-div\"]/div[2]/table/tbody/tr[1]/td[5]/a")); 
     arr1.click(); 
     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 

     WebElement dep1 = driver.findElement(By.xpath("//*[@id=\"ui-datepicker-div\"]/div[1]/table/tbody/tr[2]/td[7]/a")); 
     dep1.click(); 
     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 


    Select curr1 = new Select(driver.findElement(By.xpath("//*[@id=\"ctl00_mainContent_DropDownListCurrency\"]"))); 
    curr1.selectByVisibleText("INR"); 
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 

    driver.findElement(By.xpath("//*[@id=\"ctl00_mainContent_btn_FindFlights\"]")).click(); 

    WebElement rate = driver.findElement(By.xpath("//*[@id=\"taxAndFeeInclusiveDivBody\"]/h4[1]/span[1]")); 

    if (Float.parseFloat(rate.getText().replaceAll(",", "")) < 9000) { 
     driver.findElement(By.xpath("//*[@id=\"ControlGroupSelectView_AvailabilityInputSelectView_CheckBoxDefenseAgreement\"]")).click(); 
     driver.findElement(By.xpath("//*[@id=\"continue-to-contact-page\"]/span[1]")).click(); 
    } 
    // filling contact details 
    Select sal = new Select(driver.findElement(By.xpath("//*[@id=\"CONTROLGROUPPASSENGER_ContactInputPassengerView_DropDownListTitle\"]"))); 
     sal.selectByVisibleText("MR"); 

} 


} 
+0

は、あなたのHTMLマークを投稿できる使用することができますあなたの