Record the bugs that I have located for 2 days, stick to it, and the problem will eventually be solved.

Insert picture description here
Background: During the execution of the use case, the error "str" ​​has no attribute'findele' was reported, the
solution:
(1) First, the click() method was called to report an error, and the error was reported: "str" ​​has no attribute'findele',
(2) Tried 2 God, various methods countless times, finally locate the problem of findele, >>> debug this method separately. Later, I still reported an error, and when I had the idea, I deleted all the
sangyan stuff in the method, as follows: def findele(self, *args):
return self.driver.find_element(*args) and there is
only one left. I didn't report this error and finally solved it. I was really drunk. As for why I reported an error after adding an exception judgment, continue to locate.
(2) Then an error was reported: "str" ​​has no attribute "driver"
Then, it was found that the driver in the return self.driver.find_element(*args) returned by the calling method was invalid, and the method could not recognize findele. I wanted it To identify what to do, first of all, we must inherit the class of this method. After inheriting, we call self.findele and pass it successfully. Heart is surging
Insert picture description here

(3) Then continue to click(), and find that the error continues: selenium.common.exceptions.InvalidArgumentException: Message: invalid argument:'using' must be a string. It means that we must use a string
(4) Replace the variables in click() with *args. The problem is solved:
# click on the element
def click(self, *args):
return self.findele( args).click( )
(5) Today I called the sendkey() method, and an error was reported: I was prompted to define 2 variables, but I entered 3 variables. The solution:
replace the first two variables with tuples. Pay attention to input 2 variables, the variable in the method is
args, for example:
def sendkey(self, args, value):
self.findele(*args).send_keys(value)
call: send_key((By.Id, "kw") ,'Jiao'), the first two variables are a tuple

Guess you like

Origin blog.csdn.net/weixin_45451320/article/details/112854261