单击元素不起作用:错误(AttributeError:'str'对象没有属性'presence_of_element_located')]]

问题描述 投票:-2回答:1

我想在出现时单击一个元素,但出现此错误消息:

AttributeError: 'str' object has no attribute presence_of_element_located'

这是我在Pycharm中的代码:

try:
    element = WebDriverWait(self.driver, 120).until(EC.presence_of_element_located(By.XPATH, '/html/body/div[1]/section/md-content/div/div/div/div[2]/div/div/div/div/md-content/md-tabs/md-tabs-content-wrapper/md-tab-content[1]/div/section[1]/h2/button[1]'))
    element.click()
finally:
    self.driver.quit()
<<

检查是否将
预期条件
导入为

from selenium.webdriver.support import expected_conditions as EC

然后没有覆盖EC变量,例如
EC = "//div"

...或其他

python selenium pycharm
1个回答
0
投票
预期条件
© www.soinside.com 2019 - 2024. All rights reserved.