Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
how-to-select-a-drop-menu-value-with-selenium-use-python_Python_Selenium - Fatal编程技术网

how-to-select-a-drop-menu-value-with-selenium-use-python

how-to-select-a-drop-menu-value-with-selenium-use-python,python,selenium,Python,Selenium,我想选择并单击一个选项,如图所示 我只想点击这个选项,但我无法下到下一步选择其他选项。你知道那里应该使用哪种代码吗? 谢谢看起来这是一个选择元素,所以这应该可以回答您的问题。 谢谢你更改标题。知道如何选择选项吗。我只想在那里挑第一个 from selenium import webdriver driver = webdriver.Chrome("C:/Users/bunai/PycharmProjects/chromedriver.exe") driver.get(&q

我想选择并单击一个选项,如图所示

我只想点击这个选项,但我无法下到下一步选择其他选项。你知道那里应该使用哪种代码吗?
谢谢

看起来这是一个选择元素,所以这应该可以回答您的问题。


谢谢你更改标题。知道如何选择选项吗。我只想在那里挑第一个
from selenium import webdriver
driver = webdriver.Chrome("C:/Users/bunai/PycharmProjects/chromedriver.exe")
driver.get("https://www.tppcrpg.net/login.php")

# identify username, password and signin elements
driver.find_element_by_name("LoginID").send_keys("3480199")

driver.find_element_by_name("NewPass").send_keys("12")

driver.find_element_by_class_name("submit").click()

time.sleep(1.0)
driver.get("https://www.tppcrpg.net/configure_roster.php")
time.sleep(0.1)
driver.find_element_by_xpath("/html/body/div[@id='body']/div[@id='inner']/form/ul[@id='configure']/li[1]/p[2]/input[@id='tMoves_102787072_1']").click()
time.sleep(0.1)
driver.find_element_by_xpath("/html/body/div[@id='cBox']/p[@class='center'][1]/select[@id='MoveA']").click()
from selenium.webdriver.support.select import Select

# Identify dropdown with Select
element = Select(driver.find_element_by_xpath("path to select element"))

# Select by:
element.select_by_visible_text("Text from dropdown")

# Or
element.select_by_index(0)

# Or
element.select_by_value("value from dropdown")