科学の箱

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

pandaでdataframeを利用するときの基本操作

Dataframeを作成します。 import numpy as np import pandas as pd from numpy.random import randn np.random.see …

no image

PythonでMicrosoft Visual C++ 14.0 is required エラーが出た場合

Visual Studio 2017だけでは不十分である。   https://visualstudio.microsoft.com/ja/downloads/から下記のリンク経由でBuil …

no image

空の配列を生成

numpy.empty()を使うと要素が初期化されていない配列を生成できる。要素に入る値はその時により変わるので必ず初期化後には明示的に値を設定する必要がある。 numpy.empty print(n …

no image

model.coef_の確認

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

no image

タイタニックデータでEDA-2

前回は、タイタニックデータについてはビジュアライズしてデータについて理解を深めた。 今回はデータをいじって機械学習に使えるようにする。 機械学習をするために必要な処理は3つある。 null値の置換 余 …

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

side bar top



アーカイブ

カテゴリー