2016-03-29 8 views
0

私は、iframeとAutoITで制御できる要素があるページのコントロールを自動化しようとしていました。 iframe内の[スキャン]ボタンをクリックする必要があります。フレームを切り替えるのに私はdriver.switch_to.frame("frmDemo")を使用しましたが、動作していないようです。どんな考えですか?ここでSelenium、Autoit and iframe

はコードです:

import win32com.client 
import time 
from selenium import webdriver 

autoit = win32com.client.Dispatch("AutoItX3.Control") 

# create a new Firefox session 
driver = webdriver.Firefox() 
driver.implicitly_wait(30) 
driver.get("http://example.com") 
time.sleep(2) 
driver.switch_to.frame("frmDemo") 
scanButton = driver.find_element_by_css_selector('body.input[type="button"]') 
scanButton.click() 

答えて

1

inputは、クラス、bodyのその子要素ではありません。あなたはまた、value属性

scanButton = driver.find_element_by_css_selector('value="Scan"') 
+0

おかげで試すことができbody

scanButton = driver.find_element_by_css_selector('input[type="button"]') 

ずに試してみてください。 'body'を削除すると動作します! –