科学の箱

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

すべての要素が同じ値を持つ配列を生成

配列はリストから生成できるが、numpyでは様々な方法で目的とする配列を生成できる。 すべての要素が0である配列の生成 すべての要素が1である配列の生成 すべての要素が同じ値である配列の生成 すべての …

no image

Pillowのインストールは成功しているのにエラーが出る

from . import _imaging as core ImportError: DLL load failed: The specified module could not be found …

no image

numpy.random.standard_normal()を使って標準分布の配列を生成する

numpy.random numpyにはいろいろな種類の分布関数から配列をランダムに生成するモジュールが用意されている。このモジュールはnumpy.randomと呼ばれる。 マニュアルはこちら : R …

no image

kaggle Titanic Tutorial – 10

いろいろ試しているがうまくいかないので、とりあえずAgeを正しく補完できるか調べる。 調査は線形回帰でどれくらい相関が出るかで判断する。   import numpy as nm impor …

no image

kaggle Titanic Tutorial – 9

さて今回は少し趣向を変えて別のアルゴリズムを試してみる。 アルゴリズムの試し方はこちらを参考にした。 https://www.kaggle.com/omarelgabry/a-journey-thro …

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

side bar top



アーカイブ

カテゴリー