异常描述:takes 2 positional arguments but 3 were given
原因:init()方法只取2个参数,但实际给出了3个参数
分析:
最初执行的代码是这样写:
self.__wait.until(ec.presence_of_element_located(By.XPATH, "//input[@placeholder='请输入用户名']"))相当于取到了三个参数,而presence_of_element_located类中_init_()方法是两个参数(self, locator),其中locator调用的是一个tuple元组,该元组(By.XPATH, "//input[@placeholder='请输入用户名']")作为一个整体,相当于一个参数,加上类实例化代表自身的self参数,就是只有两个参数。
因此,执行正确的写法:嵌套一层英文圆括号
self.__wait.until(ec.presence_of_element_located((By.XPATH, "//input[@placeholder='请输入用户名']")))
- positional TypeError arguments Selenium 解决方案positional typeerror arguments selenium positional typeerror arguments polygon positional typeerror argument required positional typeerror arguments given compute_class_weight positional typeerror argument positional argument required missing sqlalchemy typeerror argument multiple argument bufferinstance writepointer typeerror typeerror arguments student python typeerror countable uncaught argument