Issue
I'm trying to select an xpath element with selenium using the .format() to select the window based on external variables.
WebDriverWait({}, 10).until(EC.element_to_be_clickable((By.XPATH, var))).click().format('driver' + str(text_response_count.number + 2))
However, I keep getting the error
dict object has no attribute 'find_element'
If I put parenthesis around the {} I get
str object has no attribute 'find_element'
which seems to suggest that it is not recognizing the {} as being part of the .format().
I've tried
WebDriverWait({}, 10).until(EC.element_to_be_clickable((By.XPATH, var))).format('driver' + str(text_response_count.number + 2)).click()
and
WebDriverWait({}, 10).format('driver' + str(text_response_count.number + 2)).until(EC.element_to_be_clickable((By.XPATH, var))).click()
But nothing works. I'm assuming all of the dot statements in between are disconnecting the WebDriverWait variables from the .format() statement.
How does one make this function properly?
Edit: I also tried
driver_var = '{}'
WebDriverWait(driver_var.format('driver' + str(text_response_count.number + 2)), 10).until(EC.element_to_be_clickable((By.XPATH, var))).click()
and got
str object has no attribute 'find_element'
I don't get it. that should have worked.
Solution
Instead of format('driver' + str(text_response_count.number + 2)
, try the following syntax:
f"driver + {str(text_response_count.number + 2)}"
Answered By - C. Peck
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.