Python Forum

Full Version: Selenium fields containing a word
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi Guys,

I was wondering if it is possible using Selenium to interact with a field if it contains a word, for example:

<select id="field_10_month" name="field_10_month"
<select id="field_10_day" name="field_10_day"
<select id="field_10_year" name="field_10_year"

With the fields above if the first one contained the word: month then i would know in the script to select a month, the same idea would go for day and year

Is this even possible with selenium at the minute?

cheers guys

you mean something like this?
value = 'month'
Otherwise could you elaborate a little more? I not really sure on what your asking.
Hello :)

Kind of like:

if self.driver.find_element_by_xpath("//select[contains(text(), 'month')]"):
    print("FOUND! an element that contains the word 'month' has been found!")
    select = Select(self.driver.find_element_by_xpath("//select[contains(text(), 'month')]"))
In this mockup if the find element contains a keyword (month in this example) it will randomly select a drop down value.

Does this make sense ok? :)