0
NoSuchElementException when selecting an element from a drop down using selectByValue

Solved 1 Answers 154 Views Selenium
0 1
I am not able to select a particular value from the dropdown even though that value exists in the drop down options.

@Test
    public void testclass() throws InterruptedException
    {
        driver.get("http://www.indianrail.gov.in/between_Imp_Stations.html");
        WebDriverWait wait = new WebDriverWait(driver, 2);
        wait.until(ExpectedConditions.presenceOfElementLocated(By.name("lccp_src_stncode")));
        WebElement Source_station = driver.findElement(By.name("lccp_src_stncode"));
        Select dropdown = new Select(Source_station);
        List<WebElement> options = dropdown.getOptions();
        for(WebElement option : options){

            System.out.println(option.getText());

            }
       
        dropdown.selectByValue("CHENNAI - MAS");

    }

1 Answer

0
Best answer
0
Are you getting options printed? can you please pint output of questions?
answered by
selected by
2Comments
commented by
Yes I am getting the options printed correctly. Below is the output of the System.out statement

ABU ROAD - ABR
AGRA CANTT - AGC
AGRA FORT - AF
AGRA CITY - AGA
AHMEDABAD JN - ADI
AJMER - AII
AKOLA - AK
ALIGARH JN - ALJN
ALLAHABAD - ALD
ALLEPPEY - ALLP
ALWAR - AWR
ALWAYE - AWY
AMBALA - UMB
AMETHI - AME
AMRAVATI - AMI
AMRITSAR - ASR
ASANSOL JN - ASN
AURANGABAD - AWB
AZAMGARH - AMH
BAHRAICH - BRK
BANGALORE - SBC
BALLIA - BUI
BANGARAPET - BWT
BARRACKPORE - BP
BARAUNI JN - BJU
BAREILLY - BE
BASTI - BST
BHUSAVAL - BSL
BEGU SARAI - BGS
BELGAUM - BGM
BELLARY - BAY
BHAGALPUR - BGP
BIJAPUR - BJP
BIKANER JN - BKN
BILASPUR - BSP
BINA - BINA
BHOPAL - BPL
BHATINDA - BTI
BOKARO STL CITY - BKSC
BHUBANESHWAR - BBS
BURDWAN - BWN
BUXAR - BXR
CALICUT - CLT
CHANDIGARH - CDG
CHHAPRA - CPR
CHENNAI - MAS
COCHIN - CHTS
CHITTARANJAN - CRJ
COIMBATORE JN - CBE
DARBHANGA JN - DBG
DARJEELING - DJ
DEHRADUN - DDN
DHANBAD JN - DHN
DHARWAR - DWR
DURG - DURG
DIBRUGARH TOWN - DBRT
ERNAKULAM - ERS
ERODE - ED
FAIZABAD JN - FD
FARIDABAD - FDB
FARUKHABAD - FBD
GAYA JN - GAYA
GONDIA - G
GORAKHPUR JN - GKP
GULBARGA - GR
GUNTUR - GNT
GUWAHATI - GHY
GWALIOR - GWL
H NIZAMUDDIN - NZM
HABIBGANJ - HBJ
HAJIPUR JN - HJP
HARIDWAR JN - HW
HOWRAH - HWH
HYDERABAD - HYB
HUBLI - UBL
INDORE JN BG - INDB
ITARSI - ET
JABALPUR - JBP
JAIPUR - JP
JAISALMER - JSM
JALANDHAR CITY - JUC
JAMMU - JAT
JHANSI JN - JHS
JODHPUR - JU
KALKA - KLK
KANPUR - CNB
KANYAKUMARI - CAPE
KATHGODAM - KGM
KATPADI - KPD
KOLKATA - HWH
KOTA JN - KOTA
KOTTAYAM - KTYM
KAZIPET - KZJ
LUCKNOW - LKO
LUDHIANA - LDH
MADGAON - MAO
MADURAI - MDU
MAHAMANDIR - MMC
MANGALORE - MAQ
MANMAD - MMR
MATHURA JN - MTJ
MAU JN - MAU
MEERUT CITY - MTC
MORADABAD - MB
MUGHAL SARAI - MGS
MUMBAI - BCT
MUMBAI CST - CSTM
MYSORE - MYS
NAGPUR - NGP
NASIK - NK
NELLORE - NLR
NEW JALPAIGURI - NJP
NEW DELHI - NDLS
PALGHAT - PGT
PANIPAT JN - PNP
PATIALA - PTA
PATNA JN - PNBE
PUNE JN - PUNE
PURI JN - PURI
PUTTAPARTHI OA - PTBY
RAE BARELI JN - RBL
RAIGARH - RIG
RAIPUR - R
RAMESWARAM - RMM
RANCHI - RNC
RANCHI ROAD - RRME
RATLAM - RTM
RATNAGIRI - RN
REWA - REWA
ROHTAK - ROK
RISHIKESH - RKSH
ROORKEE - RK
ROURKELA - ROU
SAHARANPUR - SRE
SALEM - SA
SANGLI - SLI
SATNA - STA
SONIPAT - SNP
SILCHAR - SCL
SIMLA - SML
SIVAKASI - SVKS
SURAT - ST
TATANAGAR JN - TATA
TENKASI JN - TSI
THANE - TNA
THANJAVUR - TJ
TIRUPATI - TPTY
TIRUCHIRAPALLI - TPJ
TRICHUR - TCR
TRIVANDRUM - TVC
TUTICORIN - TN
UDAIPUR - UDZ
UJJAIN - UJN
VADODARA - BRC
VARANASI JN - BSB
VASCO DA GAMA - VSG
VIJAYAWADA JN - BZA
VISHAKAPATNAM - VSKP
WARANGAL - WL
WARDHA - WR
commented by
Your value is correct.

Kindly try sendkeys

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.



Top Contributors

...