AttributeError: 'Sxgl' object has no attribute 'driver' 解决方法之一


使用unittest框架编写selenium代码,运行时常见错误

line 20, in setUp
self.driver.get("http://11.0.6.74:8050/#/Index")
AttributeError: 'Sxgl' object has no attribute 'driver'

解决方法:

如果 def setUp(self): 方法中声明了:driver=webdriver.Chrome(),同时,其他方法中有声明:driver=self.driver

那么,把def setUp(self)方法中所有driver前面加 .self,如下图:就可以解决了。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM