Python Forum
Selenium press "select option" button (SOLVED) - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Selenium press "select option" button (SOLVED) (/thread-40502.html)



Selenium press "select option" button (SOLVED) - kucingkembar - Aug-10-2023

sorry for my bad english,
i tried this since yesterday,
i tried to press a button that turn out that button is "select option",
i dont know how, but the page do nothing when i "select_by_index(1)"

this is the code

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from bs4 import BeautifulSoup
import time

service = Service(executable_path=r'/usr/bin/chromedriver')
options = webdriver.ChromeOptions()
#options.add_argument('--headless')
options.add_argument("--disable-notifications")
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(service=service, options=options)
driver.get("https://bravedown.com/id/bilibili-downloader/")
print(driver.page_source)
inputElement = driver.find_element(By.ID, 'link')
inputElement.send_keys('https://www.bilibili.com/video/BV1ru411G7f2')
inputElement.send_keys(Keys.ENTER)
time.sleep(20)
print(driver.page_source)
soup = BeautifulSoup(driver.page_source, 'html.parser')
drop_down_node = driver.find_element(By.ID, 'render_video')
drop = Select(drop_down_node)
drop.select_by_index(1)
time.sleep(10)
input("press any key to continue...")
driver.quit()
i don't know how i continue this code,
i will appreciate google keyword, google link, clue, or anything else,
please help me

EDIT : after i update the selenium, the code is working