1
如何從Python的如何使用硒/ Pyautogui Python的
代碼使用Selenium/Pyautogui下拉列表中選擇 '全部' 下拉列表中選擇 '所有':
driver = webdriver.Chrome()
driver.get("http://www.google.com")
scrolldown = driver.execute_script("window.scrollTo(0,
document.body.scrollHeight);")
displayall = driver.find_element_by_css_selector('.k-icon.k-i-arrow-
s').click()
x,y = pyautogui.position()
z = y+25
movemouse = pyautogui.moveTo(x,z, duration=0.25)
movemousepos = pyautogui.position()
pyautogui.click()
HTML:
<span title="" class="k-widget k-dropdown k-header"
unselectable="on" role="listbox" aria-haspopup="true" aria-
expanded="false" tabindex="0" aria-owns="" aria-disabled="false"
aria-readonly="false" aria-busy="false" style="" aria-
activedescendant="36e1dea4-df6d-4f58-afd5-77d93c0f7251">
<span unselectable="on" class="k-dropdown-wrap k-state-default">
<span unselectable="on" class="k-input">All</span>
<span unselectable="on" class="k-select">
<span unselectable="on" class="k-icon k-i-arrow-s">select</span>
</span></span>
<select data-role="dropdownlist" style="display: none;">
<option value="all" selected="selected">All</option>
<option value="10">10</option><option value="20">20</option>
<option value="50">50</option></select></span>
有沒有錯誤,但它不工作。有什麼建議嗎?
我不明白其中的下拉你想要的類別或子 – iamsankalp89
[硒的可能重複的值 - Python的 - 掇下拉菜單選項值](https://stackoverflow.com/questions/7867537/selenium-python-drop-down-menu-option-value) – Guy
看@alecxe答案,而不是接受的答案。 – Guy