大家好,我在一个爬虫framework中,建立了两个.py档案
第一个档案中有一个class SeleniumDriver
第二个档案中有一个class LoginPage
LoginPage继承SeleniumDriver
在SeleniumDriver中
def __init__(self,driver):
self.driver = driver
在LoginPage中
def __init__(self,driver):
super().init__(driver)
self.driver = driver
在SeleniumDriver中,有很多使用self.driver的function
ex. self.driver.find_element()
如果我没有在LoginPage的__init__()中用super()
,会调用不到SeleniumDriver中的方法吗? 为什么呢?
谢谢
PS.
code
class SeleniumDriver ==> https://goo.gl/A3n4jR
class LoginPage ==> https://goo.gl/NJFw1N
selenium老师的解释(看不懂) : We are using it to initialize the driver instance in the parent class│
If the parent class does not know about the driver instance, you will be able
to call the methods from the parent class but they will give an exception
because they do not know about driver methods│