I am facing problem with Selenium web driver in accessing List box Values.
I am able to paste value and pass the class name of list which i want to select, basically i have to select every time the very first option which is displayed in the list
1 driver.get('https://my.maerskline.com/schedules/vessel')
2 button = driver.find_element_by_id("s2id_b-vesselCode")
3 button.click()
4 button1 = driver.find_element_by_id("s2id_autogen1_search")
5 button1.send_keys(Vessel_name)
6 button3 = driver.find_element_by_id("select2-results-dept-0 select2-result select2-result-selectable")
7 button3.click()
8 button2 = driver.find_element_by_id("schedulesByVesselSearchButton")
button2.click()
Line 6 gives me below error
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element:
{"method":"id","selector":"select2-results-dept-0 select2-result
select2-result-selectable"} (Session info: chrome=55.0.2883.87)
(Driver info: chromedriver=2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 6.1.7601 SP1 x86_64)
Any idea how I can get this done? Any more information needed let me know. Thanks
updated Code
if Vessel_name != "":
#driver.get('https://my.maerskline.com/vessels?searchTerm={0}'.format(Vessel_name))
print(Vessel_name)
driver.get('https://my.maerskline.com/schedules/vessel')
button = driver.find_element_by_id("s2id_b-vesselCode")
button.click()
button1 = driver.find_element_by_id("s2id_autogen1_search")
button1.send_keys(Vessel_name)
button3 =driver.find_element_by_css_selector("#select2-results-1>li:nth-child(1)")
button3.click()
#button2 = driver.find_element_by_id("schedulesByVesselSearchButton")
#button2.click()
try:
soup = BeautifulSoup(driver.page_source)
and finannly
– Er Gaurav Chhabra Jan 11 '17 at 14:14