1
Selenium WebdriverとPython 2.xのリストから選択値に問題があります。私のテストサイトのHTMLコードを見てください。私の問題は私のSelenium Webdriverコードです。私のテストサイトからSelenium Webdriver Python 2.x - リストから値を選択
HTML(allegro.pl)
<div class="input-text-wrapper">
<input id="main-search-text" type="text" name="string" x-webkit-speech autocomplete="off" required="required"
class="autofocus"
value=""
placeholder="czego szukasz?"/>
</div>
<select class="search-type-select" name="search_scope">
<option value="">wszystkie działy</option>
<option value="electronics">Elektronika</option>
<option value="fashion.beauty">Moda i uroda</option>
<option value="household.health">Dom i zdrowie</option>
<option value="baby">Dziecko</option>
<option value="culture.entertainment">Kultura i rozrywka</option>
<option value="sports.leisure">Sport i wypoczynek</option>
<option value="automotive">Motoryzacja</option>
<option value="collections.art">Kolekcje i sztuka</option>
<option value="company.services">Firma</option>
<option value="user">Użytkownicy</option>
<option value="closed">Zakończone</option>
<option class="custom-search-type"></option>
</select>
<input type="submit" value="Szukaj" class="sprite search-btn"/>
<div class="search-type-select"
>
<ul>
<li class=""><a class="active" href="#">wszystkie działy</a></li>
<li class="department"><a href="#electronics">Elektronika</a></li>
<li class="department"><a href="#fashion.beauty">Moda i uroda</a></li>
<li class="department"><a href="#household.health">Dom i zdrowie</a></li>
<li class="department"><a href="#baby">Dziecko</a></li>
<li class="department"><a href="#culture.entertainment">Kultura i rozrywka</a></li>
<li class="department"><a href="#sports.leisure">Sport i wypoczynek</a></li>
<li class="department"><a href="#automotive">Motoryzacja</a></li>
<li class="department"><a href="#collections.art">Kolekcje i sztuka</a></li>
<li class="department"><a href="#company.services">Firma</a></li>
<li class="separator-top"><a href="#user">Użytkownicy</a></li>
<li class=""><a href="#closed">Zakończone</a></li>
</ul>
<strong data-filter-id="" title="wszystkie działy">
<span>wszystkie działy</span>
<i class="sprite"></i>
</strong>
</div>
マイセレンwebdriverをコード:
driver = webdriver.Firefox()
driver.implicitly_wait(30)
driver.maximize_window()
driver.get("http://www.allegro.pl")
searchbox = driver.find_element_by_id("main-search-text")
searchbox.send_keys("what you search")
#And here is my problem, i wanna choose something from the list:
searchlist = find_element_by_css_selector("select#search_scope/option[text()='Elektronika']").click()
#I try another think here, but also not working:
#Select(driver.find_element_by_css_selector("select#search_scope")).select_by_value(baby).click()
私は "search_scope" ロケーションバーで見られますが、ではありません値が選択されました。
前と同じ反応です。 URLで私は "search_scope ="を見ることができますが、価値はありません。私のコード: – PythonLearn
この「反応」とはなんですか?例外ログを共有できますか? – Andersson
@PythonLearn、)更新の答えをチェックして、私は – Andersson