0

This page page has a list of phone codes, I need to change the selected country code, it can be done by adding this

 <option value="ua">380+ country</option> <option value="ug">256+ country</option> ---> <option value="uk" **selected**="">44+ country</option> <option value="uy">598+ country</option> <option value="uz">7+ country</option> <option value="ve">58+ country</option> <option value="vn">84+ country</option> <option value="ws">685+ country</option> <option value="ye">967+ country</option> <option value="yu">381+ country</option> <option value="za">27+ country</option> 

so how can I write 'selected' anywhere I want with selenium?

2
  • one way I can think of is to get the whole html document, and then string format it, then run it locally, so as an html document it will at least have the visual appearance
    – Matiiss
    CommentedJul 12, 2021 at 8:38
  • can this be an answer here
    – Ayan Adel
    CommentedJul 12, 2021 at 8:41

1 Answer 1

2

You have shown only options tag from HTML structure.

They must be child of Select tag in HTML.

Basically Select and option tags are meant to build a drop down.

You can select them like this :

menu = Select(driver.find_element(By.XPATH, "xpath of select web element")) menu.select_by_value("ua") 
0

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.