Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to select an element in list box by selenium in python

I am totally new in python. I want to select an element in list box. I know it is such an easy task but I don’t know why it is not working on my computer.
The URL is:

https://biruni.tuik.gov.tr/disticaretapp/menu_ing.zul

how can I choose one of them with with select?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

from selenium import webdriver
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.support.ui import Select

driver = webdriver.Chrome('C:\Webdriver\chromedriver.exe')
driver.get('https://biruni.tuik.gov.tr/disticaretapp/menu_ing.zul')
time.sleep(2)

I try a lot to select by:

select.select_by_visible_text("Partner country/ Country Groups")

or

driver.find_element(By.XPATH,'//*[@id="yXAPg2-cave"]').click()

But it does not work! I don’t know why! May you help me?

>Solution :

You can click the desired element by selecting the element on the text it contains. The following code should work fine.

element = driver.find_element(by=By.XPATH,value='//*[contains(text(), "Partner country/ Country Groups")]')                                                                                                            
element.click()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading