【问题标题】:why it will show AttributeError: module 'self' has no attribute 'driver'为什么会显示 AttributeError: module \'self\' has no attribute \'driver\'
【发布时间】:2022-10-21 23:43:18
【问题描述】:

我想在结账时填写信用卡,但我找不到

self.driver.switch_to.frame()
self.driver.switch_to.frame("number7fe57559-0283-43ef-90c4-484c5c17c4f1").click```

it show 
```File "C:\Users\harry\PycharmProjects\pythonProject\main.py", line 34, in <module>
    self.driver.switch_to.frame()
AttributeError: module 'self' has no attribute 'driver'```
https://www.goopi.co/

【问题讨论】:

  • 您需要显示更多代码。奇怪的是错误是“模块'self'没有属性......”因为这意味着你在某处有一个import self。 self 通常是类方法中第一个参数的名称,它指的是类的实例。所以看起来你已经从方法中复制并粘贴了一些代码并粘贴到你的 main.py 的顶层?
  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如它目前所写的那样,很难准确地说出你在问什么。

标签: python selenium selenium-webdriver


【解决方案1】:

您只能在 python 类中使用 self 。尝试不使用它。

【讨论】:

    【解决方案2】:

    enter image description here

    我正在尝试使用 python 自动填充付款明细,当我尝试不使用 self 时仍然无法运行它enter image description here

    【讨论】:

      猜你喜欢
      • 2022-12-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-04
      • 2020-05-26
      • 2023-01-16
      • 2015-09-26
      相关资源
      最近更新 更多