科学の箱

科学・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

StringIOを使ってread_csvのテストをしてみる

pandasで操作できるファイルは様々なあるが、csvはJSONと並んで取り扱うことが多いファイルである。ちょっとしたコードの検証をしたいときに毎回csvを用意して、read_csv()で読み込むのは …

no image

初めてのmatplotlib

matplotlibを使えばpythonで様々なグラフをデータから作成できる。初めてのmatplotlibということで、単純なグラフを作成する。 まずはmatplotlibを読み込む >> …

no image

dataframeのgroupbyで使えるメソッド

Dataframeでgroupby経由で使宇メソッド。基礎統計で大事そうなものだけを記載。 mean() sum() std() count() max(), min() describe() Rel …

no image

kaggle Titanic Tutorial – 8

前回の結果がいまいちだった。これまではAgeは平均値でNullを埋めていた。平均値では明らか実際のデータと差異が出ると考えられる。そのためAgeがない情報についてより正確なAgeで補完するようにした。 …

no image

model.coef_の確認

重回帰分析で重みを確認するには下記を利用する。 model.coef_ ただしこれだと有効桁数が分かりにくいので有効桁数を3桁にして、さらに指数を展開する。 np.set_printoptions(p …

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

side bar top



アーカイブ

カテゴリー