AttributeError: 'NoneType' object has no attribute 'click' reasons, the solution

AttributeError: 'NoneType' object has no attribute 'click' What this means is an element not click this property. Similarly, AttributeError: 'NoneType' object has no attribute 'send_keys ()', the input value is no attribute.

When the python code this problem, there are generally two cases.

One does not find this element, for example, you want to click on "Language and Input" in the settings, but did not locate this element. In the page page, the way you define the right, to find elements by id, xpath, and other methods are also right. When life and death can not find the reason, the reason being given is not scanned uiautomatorviewer to control. For example, scanning is the first screen, you need to slide the elements of the third screen to appear. In the first screen you can not find the elements it will complain. This is the first case.

The second situation is indeed an element uiautomatorviewer scanned. But also an error, it did not explain this element this property. But this probability is very small, because you do not add the button to clear the operation, click operation to add a text box.

 

 More pictures, for example, is the first cause of the error, you can not find elements by find_ele_ById_And_content method. Solution: You can find this method defined in base_action.py file,

find_ele_ById_And_content DEF (Self, LOC, Content): 
List = self.driver.find_elements (By.ID, LOC [. 1])
for in List I:
IF i.get_attribute ( 'text') == Content:
return I
This line correct, then we step by step to print, if what step does not print, which line the error,
find_ele_ById_And_content DEF (Self, LOC, Content): 
List = self.driver.find_elements (By.ID, LOC [. 1])
Print ( 'the method proceeds to which')
Print (len (List)) on line and this line # is to check the length of the list, print (list) is a list of the contents. To the purpose is to facilitate the line you look at this line of print position
for i in list:
T1 = i.get_attribute ( 'text')
property print (t1) # print list of elements in the text
IF T1 == Content:
Print (i ) # print elements
return i
this is an idea with this method is still not solve. Solution element is not displayed in the base_action in a sliding screen to find the elements of the package, if found to return to this element , the element is operated in the page
such as clicks, typing and other operations. If the bottom of the page slide up, slide down the top of most pages, slide the rightmost left, slide to the right far left can not find, on the error.
In the next blog packaged slide operation.

Guess you like

Origin www.cnblogs.com/noon-12/p/12654258.html