こんにちは、OSSIM Web サイトでテスト アプリを作成しようとしています。Firefox を使用して Python 2.7 でセレンを使用しています。Web サイトが開いたら、iframe にアクセスする必要があります。
<iframe id="main" name="main" src="/ossim/forensics/base_qry_main.php?clear_allcriteria=1&num_result_rows=-1&submit=Query+DB&current_view=-1&sort_order=time_d&time%5B0%5D%5B0%5D=+&time%5B0%5D%5B1%5D=%3E%3D&time%5B0%5D%5B2%5D=04&time%5B0%5D%5B3%5D=21&time%5B0%5D%5B4%5D=2018&time%5B0%5D%5B5%5D=12&time%5B0%5D%5B6%5D=&time%5B0%5D%5B7%5D=&time%5B0%5D%5B8%5D=+&time%5B0%5D%5B9%5D=+&time_range=day&m_opt=analysis&sm_opt=security_events" style="visibility: visible; height: 2543px;"></iframe>
このようにフレームにアクセスします
driver.switch_to.frame(driver.find_element_by_name('main'))
これまでのところ、私はクリックする必要があるボタンを見つけました:
adv_search_button をクリックする必要があります。これは簡単なので、次のようにします。
driver.find_element_by_id('adv_search_button').click()
ここで、ある種のフレームが必要なフォームで表示され、アクセス方法がわからないという問題が発生します。表示されるフォームは次のとおりです。
$('#adv_search_button').click(function(){
GB_show("Búsqueda avanzada","/forensics/base_qry_form.php", 550, 900);
return false;
何度も試した後、自分でそれを理解しようとすることをあきらめ、アイデアを得るためにkatalonオートメーションレコーダーを試しましたが、それがどのように行われているかわかりません.(しかし、それは機能しています)ここに私ができるセレンコードがあります'Python に変換しない:
selenium.open("URL")
selenium.selectFrame("index=0")
selenium.click("id=adv_search_button")
selenium.selectFrame("relative=parent")
selenium.selectFrame("index=1") -< Here is where i want to be , to get the code and interact with the website.
私はやろうとしました:
driver.switch_to.frame("index=0")
これは私が得るエラーです。
>>> driver.switch_to.frame("index=0")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\switch_to.py", l
ine 87, in frame
raise NoSuchFrameException(frame_reference)
selenium.common.exceptions.NoSuchFrameException: Message: index=0