python-3.xselenium-webdriverselenium-chromedriver

Selecting a drop down menu of a country list results in "'str' object is not callable"


I'm writing a python script to use selenium to fill out a form from a CSV file. So far most of it is working, except selecting the country list. I tried both by ID and XPATH. Here is what I have for the drop down menu part:

Country=driver.find_element(By.ID('select-145')).get_attribute("innerHTML")
select=Select(Country)
Country.select_by_visible_text(ClientCountry)

The error I'm getting is this:

Country=driver.find_element(By.ID('select-145')).get_attribute("innerHTML") ^^^^^^^^^^^^^^^^^^^ TypeError: 'str' object is not callable


Solution

  • K.. After lots and lots of troubleshooting... I finally got it figured out...

    Country=driver.find_element(By.XPATH, "full-xpath-pasted-here"); countryselect=Select(Country); countryselect.select_by_visible_text(ClientCountry)

    Definitely thought I had this before, but I think I had the wrong variable in the third command at the beginning. I think I had the ClientCountry and not countryselect.