科学の箱

科学・IT・登山の話題

Python

seleniumでWebElement object is not iterableが出るときの対処方法

投稿日:

iterableなオブジェクトを想定して要素を取得、forループに取り込むと下記のようなWebElement object is not iterableが出る。

結論としては勘違い。

Seleniumのドキュメントを見てみる。

https://kurozumi.github.io/selenium-python/locating-elements.html

単数のオブジェクトを取得する場合には下記のメソッドを利用する。

  • find_element_by_id
  • find_element_by_name
  • find_element_by_xpath
  • find_element_by_link_text
  • find_element_by_partial_link_text
  • find_element_by_tag_name
  • find_element_by_class_name
  • find_element_by_css_selector

複数の場合にはこちら。”s”一文字でずいぶん結果が変わってくる。。。

  • find_elements_by_name
  • find_elements_by_xpath
  • find_elements_by_link_text
  • find_elements_by_partial_link_text
  • find_elements_by_tag_name
  • find_elements_by_class_name
  • find_elements_by_css_selector

 

メタ情報

inarticle



メタ情報

inarticle



-Python
-

執筆者:


comment

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

関連記事

no image

生成した配列をグラフで確認

生成した配列を可視化するためにはmatplotlibが利用できる。 ここでは簡単に可視化するための使い方を見てみる。 まずはnumpyとmatplolibモジュールを読み込む。以下ではnumpyはnp …

no image

蟻本 P42 硬貨の問題

貪欲法の基本 その時点で最善の手を尽くす 尽くした結果を目的とする値に反映させる。 次善の手になるようにする。 1に戻る 硬貨の問題 A=int(input()) *C,=map(int,input( …

no image

kaggle Titanic Tutorial – 4

名前から取得できるタイトルを分析に利用してみる。 タイトルは末尾に”.”がついているのでこれを利用して切り出す。 def get_title(name): if ‘.’ in …

no image

automated the boring – day7

https://automatetheboringstuff.com/chapter14/ 14章ではcsvとJSONを取り扱う。フォーマットとしては単純であるのに、なぜexcel,word, pdf …

no image

kaggle Titanic Tutorial – 7

さて今回はAgeを補完してから、元の分布と比べてみる。 def fill_age(row): condition = ( (d_train_g_m[‘Sex’] == row[‘Sex’]) &amp …

2018年11月
« 10月   12月 »
 1234
567891011
12131415161718
19202122232425
2627282930  

side bar top



アーカイブ

カテゴリー