1

http://www.nike.com/us/en_us/c/nikeid

I want to click on the 'Customize' nav link up in the top nav bar (so the one on the top, not the left) and then select Men's in the hover menu.

I can click on 'Customize', the hover menu than opens, but I am having trouble selecting Men's in that menu. I have posted my code below.

    driver.get('http://www.nike.com/us/en_us/c/nikeid')
    # open Customize hover menu in top nav bar
    men_menu = driver.find_element_by_css_selector("li[data-nav-tracking=customize]")
    actions.move_to_element(men_menu).perform()

    # click Men's
    wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "li[data-nav-tracking=men] a[data-subnav-label$=Men's]"))).click()

How do I click on the Men's link with Selenium Webdriver?

2
  • I don't see Men's menu item inside the Customize menu. May be you meant "Men" link?.. Commented Jun 6, 2016 at 15:43
  • Yes sorry, Men is what I am trying to click. Commented Jun 6, 2016 at 15:49

1 Answer 1

2

Just fix your selector to match the Men link:

wait.until(EC.visibility_of_element_located(
    (By.CSS_SELECTOR, "li[data-nav-tracking=customize] [data-nav-tracking=men] a"))).click()
Sign up to request clarification or add additional context in comments.

5 Comments

If I manually click 'Customize' and then 'Men', it takes me to store.nike.com/us/en_us/pw/mens-nikeid-shoes/…, this is what i am trying to accomplish with selenium webdriver.
@Ben interesting. What do you mean by stopped working? Any errors, what is happening? FYI, here is what I'm executing and what is working for me: gist.github.com/alecxe/0c048b7f10b45a95790fdd6c372e985f.
I have resolved the issue. The problem was that 'wait' and 'driver' were both defined in a different unit test, so I defined in this test as well and now it works.
thanks for the help though, you are like the selenium master of SO

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.