[Tutor] click() performs unreliably

2018-11-26 Thread stephen.m.smith
I am trying to click on one of two buttons on a page. Here is an image of
the relevant portion of the page, the HTML and the two xpaths.

 

 



 

 



 

/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

 

 

 

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] click() performs unreliably

2018-11-26 Thread Alan Gauld via Tutor
On 26/11/2018 10:21, stephen.m.sm...@comcast.net wrote:
> I am trying to click on one of two buttons on a page. Here is an image of
> the relevant portion of the page, the HTML and the two xpaths.

I assume this is related to your earlier post about using
Selenium? If so, you will probably get a better response
asking on the Selenium help fora since this list is really
focused on core Python and the standard library. Relatively
few members will be using Selenium.

The Selenium support pages has several suggestions:

https://www.seleniumhq.org/support/


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A required question

2018-11-26 Thread Mats Wichmann
On 11/25/18 8:54 PM, Asokan Pichai wrote:
> On Sat, Nov 24, 2018, 14:33 Avi Gross  
>> David,
>>
>> As I suspected. Yes, I am aware how to do those things. Just wondered if
>> anyone automated the process so a fairly simple interface worked.
>>
> Does the requirements.txt file (associated with pip IIRC) does most of what
> you want?

If so, then also worth looking at the pipfile and pipenv which are
aiming to improve on the experience.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A retired question

2018-11-26 Thread Avi Gross
After saying I dropped my request, short replies keep coming.

Let me reply in this context:

Would there be BUILT-IN tools that can be expected to already be everywhere
which can be used at the top of a program you write and distribute to
quickly check if the rest of the program  has the resources it
needs to run probably.

I am not currently planning on designing or implementing anything. It was an
academic question.

I was thinking along the lines of slightly advanced ways functions can start
with a group of assertions testing what is expected and quit if not set
right. They use assert().

Some of what is being suggested may have useful pieces you can use in doing
something like this. But I note that the ability to package things is not
something most users need. You need a kernel of guaranteed software you can
count on in order to test if other required elements and conditions can be
met.

Realistically, there are so many variations on python and how you can get
copies distributed that I cannot assume that if I write a routine that uses
numpy or pandas, as I have been doing, will be installed before a user makes
use of the software. And, you can even build your own versions of python
while leaving out or including things. It is nice to be flexible. But then
you may need to stock to some version from prehistoric times using
relatively few features AND being careful to not use features that were
later changed or removed.

Why bother?

OK, here is the solution. At the beginning of the script put out a big
warning telling the user that if they do not have all the required software
they are proceeding at their own risk and take full responsibility if
something weird happens before the software dies. Hitting ENTER will be
considered acceptance of the terms!

Again. Dropped. Moving on. 

If the goal here is to tutor, no need to share complex solutions but rather
help students learn how to look at their problems and see what kinds of data
and logic to apply in what order and then how to debug the inevitable
mistakes like a missing comma.

-Original Message-
From: Tutor  On Behalf Of
Mats Wichmann
Sent: Monday, November 26, 2018 10:23 AM
To: paso...@gmail.com
Cc: tutor@python.org
Subject: Re: [Tutor] A required question

On 11/25/18 8:54 PM, Asokan Pichai wrote:
> On Sat, Nov 24, 2018, 14:33 Avi Gross  
>> David,
>>
>> As I suspected. Yes, I am aware how to do those things. Just wondered 
>> if anyone automated the process so a fairly simple interface worked.
>>
> Does the requirements.txt file (associated with pip IIRC) does most of 
> what you want?

If so, then also worth looking at the pipfile and pipenv which are aiming to
improve on the experience.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A retired question

2018-11-26 Thread Steven D'Aprano
On Mon, Nov 26, 2018 at 06:09:30PM -0500, Avi Gross wrote:

> Would there be BUILT-IN tools that can be expected to already be everywhere
> which can be used at the top of a program you write and distribute to
> quickly check if the rest of the program  has the resources it
> needs to run probably.

No.


-- 
Steve
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A retired question

2018-11-26 Thread Mats Wichmann
On 11/26/18 5:55 PM, Steven D'Aprano wrote:
> On Mon, Nov 26, 2018 at 06:09:30PM -0500, Avi Gross wrote:
> 
>> Would there be BUILT-IN tools that can be expected to already be everywhere
>> which can be used at the top of a program you write and distribute to
>> quickly check if the rest of the program  has the resources it
>> needs to run probably.
> 
> No.

Indeed. But the whole idea of the Python "batteries included" concept is
that Python + standard library gets you an impressively long way without
resorting to external modules, and that set is a promise.


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor