0

Assume the following button is present on a page:

<input type="submit" name="next_btn" value="Next" onclick="gonext();" id="btnNext">

Additionally, when clicked manually, the page takes ~3-6 seconds to load and display new data.

I've tried respectively:

driver.find_element_by_name("next_btn").submit()

and

driver.find_element_by_name("next_btn").click()

Neither does anything in this case, so I figured I could try and execute the gonext() JavaScript, only to be met by an attribute error as such: AttributeError: 'NoneType' object has no attribute 'submit - have also tried with .click().

Thanks in advance!

vham
  • 101
  • 1
  • 1
  • 10

1 Answers1

2

Assuming that you are coding in Python, you should be doing:

element = driver.find_element_by_name('next_btn');
element.click();

Or you may use:

element = driver.find_element_by_id('btnNext');
element.click();

Let me know if this helps you.

Yuval Pruss
  • 8,716
  • 15
  • 42
  • 67
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • @yoshiserry You won't be clicking this same button with same id multiple times in a real time _usecase_. Moreover attempting to click the same button with same id multiple times will raise [stalelementreferenceexception](https://stackoverflow.com/questions/44838538/staleelementreference-exception-in-pagefactory/44844879#44844879) – undetected Selenium Mar 27 '18 at 11:18
  • sorry the same button with the same name not _id – yoshiserry Mar 27 '18 at 11:38
  • @yoshiserry I believe `name` attribute is also unique just like `id` attribute. Hence the similar logic applies as per my previous comment _you won't be clicking this same button with same id multiple times in a real time usecase. Moreover attempting to click the same button with same id multiple times will raise stalelementreferenceexception_. – undetected Selenium Mar 27 '18 at 11:40