u***@comcast.net
2018-11-26 16:10:38 UTC
I am trying to click on one of two buttons on a page. Here is athe HTML and
the two xpaths.
div class="button_contianer">
<a class="go_back_button" href-"#">Go Back</a> event
<a class+submit_request_button" href="#">Submit Request</a> event
/html/body/div[3]/div/div[3]/div[6]/div/div[2]/div/div[3]/a[1]
/html/body/div[3]/div/div[3]/div[6]/div/div[2]/div/div[3]/a[2]
I have made numerous attempts to click on the first button with very
limited success â it works maybe 25% of the time. Looking through the code
snippet below, you will be able to see some of the various techniques I
have tried â I commented out some of the attempts when they failed so that
I could remember what I have tried. I have looked extensively online at
previous posts, but canât find anything that works reliably. The code
executes fine and I can see the button depressed and get routed to the
previous page, but the other actions associated with the click (backing out
the previous step) are not performed. Yet if I pause the code and intervene
by clicking on the button by hand, the routing takes place and the
associated steps are executed. When I click on the second button (with a
virtually identical xpath address) the processing works as it should.
I have tried to find the element by xpath and class name, I have tried
commands with a click() at the end of the find, I have tried
.send_keys(â\nâ) at the end of the find and other approaches as well. A
simple find_element_by_xpath with the address for the second button works
100% of the time. I really donât understand what I am missing and canât
seem to find another method to try. Thanks for any and all thoughts.
## br.get('chrome://settings/')
##
br.execute_script('chrome.settingsPrivate.setDefaultZoom(1.5);')
br.find_element_by_xpath("/html/body/div[3]/div/div[3]/div[6]/div/div[2]/div/div[3]/a[1]").click()
#br.find_element_by_class_name("go_back_button").send_keys("\n")
# Back out time (test mode)
#print(thread, "Test mode - backing out time(s)")
#result = xpath_search(self, xpath_for_go_back_button, br, 10,
do_click)
##
## button =
br.find_element_by_xpath("//*[@id='main']/div[6]/div/div[2]/div/div[3]/a[1]")
## button.click()
## #sleep(20)
## result =
xpath_search(self,"/html/body/div[3]/div/div[3]/div[6]/div/div[2]/div/div[3]/a[1]",
br, 5, do_click)
## print("Back out time result =", result)
## if result == failure:
## self.queue.put("(" + thread + ") Unable to back out time")
## if thread == "1":
## endApplication(self, br, thread)
#### return
## try:
## WebDriverWait(br,
5).until(EC.element_to_be_clickable((By.XPATH, xpath_for_go_back_button)))
## back_out =
br.find_element_by_xpath(xpath_for_go_back_button)
## back_out.click()
## print("Cancel tee time worked")
## except NoSuchElementException:
## print("Cancel tee time did not work")
## return
the two xpaths.
div class="button_contianer">
<a class="go_back_button" href-"#">Go Back</a> event
<a class+submit_request_button" href="#">Submit Request</a> event
/html/body/div[3]/div/div[3]/div[6]/div/div[2]/div/div[3]/a[1]
/html/body/div[3]/div/div[3]/div[6]/div/div[2]/div/div[3]/a[2]
I have made numerous attempts to click on the first button with very
limited success â it works maybe 25% of the time. Looking through the code
snippet below, you will be able to see some of the various techniques I
have tried â I commented out some of the attempts when they failed so that
I could remember what I have tried. I have looked extensively online at
previous posts, but canât find anything that works reliably. The code
executes fine and I can see the button depressed and get routed to the
previous page, but the other actions associated with the click (backing out
the previous step) are not performed. Yet if I pause the code and intervene
by clicking on the button by hand, the routing takes place and the
associated steps are executed. When I click on the second button (with a
virtually identical xpath address) the processing works as it should.
I have tried to find the element by xpath and class name, I have tried
commands with a click() at the end of the find, I have tried
.send_keys(â\nâ) at the end of the find and other approaches as well. A
simple find_element_by_xpath with the address for the second button works
100% of the time. I really donât understand what I am missing and canât
seem to find another method to try. Thanks for any and all thoughts.
## br.get('chrome://settings/')
##
br.execute_script('chrome.settingsPrivate.setDefaultZoom(1.5);')
br.find_element_by_xpath("/html/body/div[3]/div/div[3]/div[6]/div/div[2]/div/div[3]/a[1]").click()
#br.find_element_by_class_name("go_back_button").send_keys("\n")
# Back out time (test mode)
#print(thread, "Test mode - backing out time(s)")
#result = xpath_search(self, xpath_for_go_back_button, br, 10,
do_click)
##
## button =
br.find_element_by_xpath("//*[@id='main']/div[6]/div/div[2]/div/div[3]/a[1]")
## button.click()
## #sleep(20)
## result =
xpath_search(self,"/html/body/div[3]/div/div[3]/div[6]/div/div[2]/div/div[3]/a[1]",
br, 5, do_click)
## print("Back out time result =", result)
## if result == failure:
## self.queue.put("(" + thread + ") Unable to back out time")
## if thread == "1":
## endApplication(self, br, thread)
#### return
## try:
## WebDriverWait(br,
5).until(EC.element_to_be_clickable((By.XPATH, xpath_for_go_back_button)))
## back_out =
br.find_element_by_xpath(xpath_for_go_back_button)
## back_out.click()
## print("Cancel tee time worked")
## except NoSuchElementException:
## print("Cancel tee time did not work")
## return
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+***@googlegroups.com.
To post to this group, send email to selenium-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/ea8d5560-ce4e-4d63-b2d0-91e157b0d3cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+***@googlegroups.com.
To post to this group, send email to selenium-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/ea8d5560-ce4e-4d63-b2d0-91e157b0d3cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.