Reputation: 51
I know this question has been asked a million times here and I have tried them all, I still can't get my python code to click a button!
So here's the result of the inspect element of said button:
<input value="New Quote" class="btn" name="new_quote_wizard" title="New Quote" type="button" onclick="if (window.invokeOnClickJS_00bC0000001TjBl) window.invokeOnClickJS_00bC0000001TjBl(this); else if (parent.window.invokeOnClickJS_00bC0000001TjBl) parent.window.invokeOnClickJS_00bC0000001TjBl(this); return false">
I've tried this:
browser.find_element_by_name('New Quote').click()
but it returns with this error:
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [name="New Quote"]
What else can I do to click this one button?
Upvotes: 0
Views: 2001
Reputation: 51
OK guys - I got it working through another stackoverflow question here: How do I click a button in a form using Selenium and Python 2.7?
So basically, I had to wait for the element!
I added these lines to my code:
wait = WebDriverWait(browser, 10) newQuote = wait.until(EC.presence_of_element_located((By.NAME, "new_quote_wizard"))) newQuote.click()
Thanks for all the help!
Upvotes: 1
Reputation: 51
Looks like problem is in the selecting element by name providing value. Try this instead:
browser.find_element_by_name('new_quote_wizard').click()
Upvotes: 4