Selenium webdriver 属性错误:';WebDriver';对象没有属性';等等';
错误消息Selenium webdriver 属性错误:';WebDriver';对象没有属性';等等';,selenium-webdriver,expected-condition,Selenium Webdriver,Expected Condition,错误消息 from behave import when, then, given from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.wait import WebDriverWait SIGN_IN_P
from behave import when, then, given
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
SIGN_IN_POPUP_BTN = (By.CSS_SELECTOR, '#nav-signin-tooltip .nav-action-inner')
@when('Click Sign In from popup')
def click_sign_in_popup_btn(context):
e = context.driver.wait.until(EC.element_to_be_clickable(SIGN_IN_POPUP_BTN))
e.click()
@then('Verify Sign In page opens')
def verify_sign_in_page_opens(context):
assert 'https://www.amazon.com/ap/signin' in context.driver.current_url, f'Url {context.driver.current_url} does not include https://www.amazon.com/ap/signin'
正在告诉您下面代码中的“WebDriver”,即您的驱动程序
'WebDriver' object has no attribute 'wait'
没有属性wait
。简单地说,WebDriver.wait
,或者在您的情况下,driver.wait
,不存在。使用等待的语法在中
在这种情况下,您的代码应该是
e = context.driver.wait.until(...)
^
或者更简单地说
from selenium.webdriver.support import expected_conditions as EC
def click_sign_in_popup_btn(context):
wait = WebDriverWait(driver, 10)
e = wait.until(EC.element_to_be_clickable(SIGN_IN_POPUP_BTN))
e.click()
*我的问题是为什么我会在下面出现这个错误:文件“features\steps\sign_in.py”,第11行,在点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击点击?
def click_sign_in_popup_btn(context):
WebDriverWait(driver, 10).until(EC.element_to_be_clickable(SIGN_IN_POPUP_BTN)).click()