0

I want to click on one element from a dropdown menu which has the following html code:

<select style="font-size:10px" onchange="dg_send('contractNonParticipationsDatagrid1-form', 'contractNonParticipationsDatagrid1', 'search', '/masterdata/datagridContractNonParticipations/dg_page/1/tabId/non-participations/id/1/licenseHolderId/1/dg_sort/dvec.full_name/dg_order/asc/dg_rowlimit/' + this.options[this.selectedIndex].value,false); "><option selected="selected" value="10">10</option><option value="25">25</option><option value="50">50</option><option value="100">100</option><option value="999999999">alle</option></select>

<option selected="selected" value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="999999999">all</option>

I would like to select the last one, so that all are displayed.

Thank you!

davvpo
  • 39
  • 3
  • Hi, What have you tried so far? – Arundeep Chohan Dec 12 '20 at 07:07
  • `display_options = browser.find_element_by_xpath("//select[contains(@onchange='this.options[this.selectedIndex]']") display_options.send_keys("alle")` – davvpo Dec 12 '20 at 07:17
  • that was my most promising approach. I actually wanted to use Seleniums Select class (https://stackoverflow.com/questions/7867537/how-to-select-a-drop-down-menu-value-with-selenium-using-python). But I find myself having problems to actually select the drop down menu. I think once it is recognised by Selenium its no problem to select any of the options of the drop down menu – davvpo Dec 12 '20 at 07:21
  • Try copying the xpath from the developer console. Then putting it into the answer below. – Arundeep Chohan Dec 12 '20 at 07:22

2 Answers2

0

To get the last option of that tag try and get it's xpath value and do the following.

from selenium.webdriver.support.select import Select
sel = Select(driver.find_element_by_xpath("//select[@style='font-size:10px']"))
sel.select_by_visible_text("all")
Arundeep Chohan
  • 9,779
  • 5
  • 15
  • 32
  • this one works. I tried to go over style but must had something wrong Thank you. Much appreciated!! – davvpo Dec 12 '20 at 08:24
0

You could also try this

from selenium import webdriver
from shutil import which

path = which("chromedriver")
driver = webdriver.Chrome(executable_path=path)
all_btn = driver.find_element_by_xpath("//select/option[contains(text(),'all'))
all_btn.click()