38
33

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Seleniumでiframe内のDOMを操作する方法

Last updated at Posted at 2016-02-24

コメントにて、driver.switch_to.frame(iframe) ではないかと、ご指摘いただきました。
最近、Selenium を使っておらず、ちゃんと確認していないのですが、適宜、いただいたコメントもご参考にされてください。

メモ。元ネタ

Seleniumで、driverインスタンスを通して、特定のDOM要素を取り出して、ボタンのクリックとかをするけど、iframe内のDOMはそのままだとアクセスできない。

先にiframeのDOMを探して、driverのswitch_to_frameを呼び出せば、そのiframeのDOMをいじれる。

iframe = driver.find_element_by_css_selector('.some-selector')
driver.switch_to_frame(iframe)
driver.find_element_by_css_selector('.some-selector-in-iframe').click()
38
33
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
38
33

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?