0
Follow
2
View

AttributeError: 'str' object has no attribute 'click' while trying to loop through XPATH tags in an array

dicongyan 注册会员
2023-01-25 01:34

You are missing a pair of parenthesis in expression.
Instead of

WebDriverWait(load_browser, 10).until(EC.presence_of_element_located(By.XPATH, Tags.resultOh))

And

WebDriverWait(load_browser, 10).until(EC.presence_of_element_located(By.XPATH, Tags.resultEx))

Try

WebDriverWait(load_browser, 10).until((EC.presence_of_element_located(By.XPATH, Tags.resultOh)))

And

WebDriverWait(load_browser, 10).until((EC.presence_of_element_located(By.XPATH, Tags.resultEx)))
dongsheng9 注册会员
2023-01-25 01:34

I think you may need to restructure your code to do something like this to get the right objects to use click() on an element:

# import webdriver
from selenium import webdriver

# create webdriver object
driver = webdriver.Firefox()

# get geeksforgeeks.org
driver.get("http://localhost:3000/")

then have the code that loops waiting on on results and selecting the next thing to try and when you are ready to find and click the element have code like this:

# get element
element = driver.find_element(By.XPATH, squares[square])

# click the element
element.click()

About the Author

Question Info

Publish Time
2023-01-25 01:34
Update Time
2023-01-25 01:34

Related Question

共享自定义AndroidJUnitRunner多个Android库模块

如何组数据的两个字段在c# Linq?

AWS SDK for JavaScript v3 PutObjectCommand错误“您提供的标头暗示功能未实现”

如何为Numpy数据创建一个datgenerator

vue2项目引入axios后,报错 Cannot read property 'FormData' of undefined,如何解决?

cocos creator 怎么监听场景内有没有敌人

从autoit运行powershell

如何在Angular中从API生成动态数据树结构?

问题模拟MassTransit方法进行测试

C语言fscanf读取文件