Selenium Python 选项单击

我需要一点帮助,看看这个:

https://img1.mukewang.com/64e47c3300019a8003190137.jpg

我想按option名为Boleto Bancario,但请查看 html

https://img.mukewang.com/64e47c3c0001a54d03980182.jpg

比我如何使用 selenium PYTHON 按第二个选项



慕仙森
浏览 109回答 2
2回答

UYOU

请检查片段。您可以通过以下方式选择valuefrom selenium import webdriverfrom selenium.webdriver.support.ui import Selectdriver = webdriver.Chrome(r'chromedriver.exe')driver.get('url')sct = Select(driver.find_element_by_id('idFormaPagamento'))sct.select_by_value('813640')您可以通过以下方式选择indexsct.select_by_index('1')

慕容708150

您可以通过三种不同的方式在任何下拉列表中选择值:select_by_value()select_by_index()select_by_visible_text()所以你可以简单地选择这样的选项:select_by_value('813640')select_by_index('1')select_by_visible_text('Boleto Bancario')希望这对你有用。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python