I am doing webscraping using selenium web driver. I have done with an option value but I have to do with option text. I have to scrape an option text and pass to your_choice=driver.find_element_by_xpath("//select/option[@value = {}]".format(b))
. Below is the code
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from bs4 import BeautifulSoup
driver = webdriver.Firefox(executable_path='./geckodriver')
url = 'https://ipr.etsi.org'
driver.get(url)
button = driver.find_element_by_id(("btnConfirm"))
button.click()
select_element = Select(driver.find_element_by_name("ctl00$cphMain$lstCompany"))
data = []
for option in select_element.options:
data.append(option.get_attribute('value'))
for a in data:
b = a
your_choice = driver.find_element_by_xpath("//select/option[@value = {}]".format(b))
# continue
your_choice.click()
python_button = driver.find_element_by_id(("ctl00_cphMain_btnSearch"))
python_button.click()
Above is the code I have done with value of the option. Now I have to do it with option text.