Python 3.5 Selenium XPath Syntax -
i'm using selenium python 3.5 scrape various websites. however, need select drop-down list keep getting error. i'm quite embarrassed can't work, xpath brand new me appreciated. truncated version of code is:
driver.implicitly_wait(4) driver.find_element_by_xpath("//select[@id='ddashowform']/ option[@value='deposits']/text()").click()
i have wait there make sure page loading because got me before. error i'm getting can't find element. help!
here snippet of relevant area of page. i'm sorry poor formatting.
<form id="ddashowform" action="https://online.wellsfargo.com/das/cgi-bin/session.cgi?sessargs=xuog_f8ddtzhif-5ivuuuwe9xqvqncvm" method="post"> <label for="transactiontype">show: </label> <select id="transactiontype" name="showtabddacommand.transactiontypefiltervalue"> <option value="all transactions" selected="selected">all transactions</option> <option value="all transactions 1 column">all transactions in 1 column</option> <option value="all transactions balance">all transactions balances</option> <option value="bill pay">bill pay transactions</option> <option value="check card">debit card / atm card transactions</option> <option value="checks">checks</option> <option value="deposits">deposits</option> <option value="withdrawls">withdrawals</option> <option value="transactiontypefilter.p2p.label">wf surepay</option> <option value="transactiontypefilter.wire.label">wires</option> </select> <label for="timefilter"> for </label> <select id="timefilter" name="showtabddacommand.timefiltervalue" size="1"> <optgroup label="" > <option value="3" selected="selected" >last 90 days</option> <option value="4" >last 6 months</option> <option value="5" >last 12 months</option> <option value="6" >last 18 months</option> <option value="7" >since last logon</option> <option value="8" >since last statement</option> <optgroup label="--------------------" class="optgroupstyle"></optgroup> <option value="11" >date range</option> </optgroup> </select>
for selecting element dropdown can use select
from selenium.webdriver.support.ui import select select = select(driver.find_element_by_id("transactiontype"))
then can select using of methods provided select
select.select_by_visible_text("all transactions")
select.select_by_value("all transactions")
select.select_by_index(1)
Comments
Post a Comment