Get the value selected in Selenium Python VBA pull-down

Get the value selected by Selenium Python Vba pull-down (Select)

Even if I search, all of them set a value in Select, and it took some time to find it, so I will make a note here as well.

Premise Windows Python 3.8 Selenium is already in use and should be handled by the driver variable

Get the value selected in Selenium Python pull-down

Use the Select class.

So you need to import the Select class. You can do various things by making the WebElement that references the Select element a Select type.

Detailed explanation for operating the Select element Official website </ b> https://www.selenium.dev/documentation/ja/support_packages/working_with_select_elements/

Get the value selected from the pull-down


from selenium.webdriver.support.select import Select
#Import Select class to work with Select element

AA = driver.find_element_by_id("A")  #Get the Select element with ID A
AAA=Select(AA)             #Create Select object You can perform various operations from this object.

#The value selected in the pull-down is
print(AAA.first_selected_option.text)

#In case of pull-down that can select multiple, you can get it in the list.
all_selected = AAA.all_selected_options  #all_selected is a list.

Get the value selected in SeleniumBasic VBA pull-down

This is easy

Get the value selected in the pull-down



Dim AA As WebElement  'Declared with WebElement type

’Get the Select element with ID A
Set AA = driver.FindElementById("A").AsSelect.SelectedOption

Debug.Print (A.Text)’The selected value has been output. I was able to

Today's tweet Speaking of which, just getting the values of text boxes and checkboxes It's been a while since I got the Select value by scraping. Recently, the number of requests has increased again, so let's get it quickly. I want more time to think.

Recommended Posts

Get the value selected in Selenium Python VBA pull-down
Get a capture of the entire web page in Selenium Python VBA
Get the desktop path in Python
Get the script path in Python
Get the desktop path in Python
Get the host name in Python
Get the value while specifying the default value from dict in Python
How to get the last (last) value in a list in Python
I can't get the element in Selenium!
Get and set the value of the dropdown menu using Python and Selenium
Get the EDINET code list in Python
[Python] Get the files in a folder with Python
Get the weather in Osaka via WebAPI (python)
Get the caller of a function in Python
Get the X Window System window title in Python
Find the divisor of the value entered in python
How to get the files in the [Python] folder
I can't click the Selenium checkbox Python VBA
Get date in Python
How to retrieve the nth largest value in Python
How to get the number of digits in Python
Note the frequently used options in Python + Selenium + Chrome
[python] Get the list of classes defined in the module
Get the result in dict format with Python psycopg2
Get the size (number of elements) of UnionFind in Python
Get the URL of the HTTP redirect destination in Python
Get the value of a specific key in a list from the dictionary type in the list with Python
Get YouTube Comments in Python
Get last month in python
Download the file in Python
Shapley value calculation in Python
Scraping with Selenium in Python
Get Terminal size in Python
[Python] Get the previous month
Explicitly get EOF in python
Get Evernote notes in Python
Python> dictionary> get ()> optional value
Get Japanese synonyms in Python
Get your heart rate from the fitbit API in Python!
Get the MIME type in Python and determine the file format
Get index of nth largest / smallest value in list in Python
Automatically get the port where Arduino is stuck in Python
Get the current date and time in Python, considering the time difference
Get the index of each element of the confusion matrix in Python
Get index of nth largest / smallest value in list in Python
Get the value of a specific key up to the specified index in the dictionary list in Python
I tried to create a Python script to get the value of a cell in Microsoft Excel
Macro (VBA) that converts the contents selected in the range in Excel into the list initialization code in Python.
Get Leap Motion data in Python.
Be careful when specifying the default argument value in Python3 series
Getting the arXiv API in Python
Python in the browser: Brython's recommendation
Get data from Quandl in Python
Save the binary file in Python
Scraping with Selenium in Python (Basic)
python> Display 3 decimals in ".3f, .3f, .3f" format / Get 3 coordinate values in the range [-1: 1]
Get the weather with Python requests
Get the weather with Python requests 2
In the python command python points to python3.8
Implement the Singleton pattern in Python
How to get the Python version