私はちょうどセレンで始まり、小さな問題に遭遇しています。 基本的に、クリックしたときに新しいタブでリンクをクリックする必要があるウェブページがあります。私はそのタブでいくつかの作業を行い、そのタブを閉じて元のウェブページ上の別のリンクをクリックしたいと思います。セレンでタブを操作する方法(Pythonで)
followinが私のコードです:
w.get("https:\link1")
opens the given link w.find_element_by_class_name("an_element").click()
clicks an element with the given class name which opens in a new tab
w.find_element_by_class_name("another_element")
clicks an element on the opened tab
w.close()
closes the opened tab
w.find_element_by_class_name("an_element").click()
clicks a new element on the previous tab
But I get the following error: w.get("https:\link1")
opens the given link w.find_element_by_class_name("an_element").click()
clicks an element with the given class name which opens in a new tab
w.find_element_by_class_name("another_element")
clicks an element on the opened tab
w.close()
closes the opened tab
w.find_element_by_class_name("an_element").click()
clicks a new element on the previous tab
しかし、私は次のエラーを取得する:
メッセージ:いいえ、そのようなセッション はどのように新しいタブウィンドウ上のいくつかの要素をクリックしていることを保証する、それを閉じることができます私は元の窓を閉じないのですか?
コードをコードとしてフォーマットしてください。書式設定のヘルプが案内します。 – JeffC
作業を終えたら、新しく開いたウィンドウを閉じる必要があります。私が窓を閉めると、元の窓にはアクセスできない。元のウィンドウにアクセスする方法に関するヘルプ? –
投稿したリンクを読んでください。おかげさまで – JeffC