1

I am trying to fill out a form that has a drop down menu for each order number.

<select name="order(889673519).box(1).shippingmethod" onclick="" onchange="" 
id="order(889673519).box(1).shippingmethod"><option value="" 
id="order(889673519).box(1).shippingmethod.blank"></option>

for each drop down menu the number inside the name css selector will change, so the first one is 889673519 but the second one will be

<select name="order(889711159).box(1).shippingmethod" onclick="" onchange="" 
id="order(889711159).box(1).shippingmethod"><option value="" 
id="order(889711159).box(1).shippingmethod.blank"></option>

What path do I use to select multiple elements with different names, so I can iterate through them selecting my options.

0

2 Answers 2

1

Use contains function:

elements = driver.find_elements_by_xpath("//select[contains(@name, 'order') and contains(@name, 'shippingmethod')]")
Sign up to request clarification or add additional context in comments.

Comments

0

To identify the <select> nodes using the following Locator Strategies:

  • Using css_selector and id attribute:

    elems = driver.find_elements_by_css_selector("select[id^='order'][id*='box'][id$='shippingmethod']")
    
  • Using css_selector and name attribute:

    elems = driver.find_elements_by_css_selector("select[name^='order'][name*='box'][name$='shippingmethod']")
    
  • Using xpath and name / id attribute:

    elems = driver.find_elements_by_xpath("//select[starts-with(@name, 'order') and contains(@id, 'shippingmethod')]")
    

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.