0

there's an html code on a web page that I'm trying to automate, and one of the line goes something like this:

<"option value = "1">ABC<"/option>"

I am wondering if there are anyways to locate this without using the value, but locating it through text ABC. I have ABC stored under a variable, and I'm planning to pass that variable in.

2 Answers 2

1
from selenium.webdriver.support.ui import Select

select = Select(driver.find_element_by_id("dropdown_menu"))
select.select_by_visible_text(abc_variable)
Sign up to request clarification or add additional context in comments.

1 Comment

Keeps saying that it can't "locate element with visible text:ABC"
0

Try by xpath..driver.find_element_by_xpath("//option[text()='ABC']")

2 Comments

but I have a variable that I stored ABC in, and I'm trying to pass in the variable.
driver.find_element_by_xpath("//option[text()='" + your_var + "']") ??

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.