2016-05-09 4 views
2

私は、Windows Detectiveの主張が「MozillaDialogClass」のウィンドウであるというダイアログを持っています。これはどのようなウィンドウで、どうすればSeleniumで処理できますか?オートチェン?

ここにウィンドウのイメージがあります。

enter image description here

AutoItのIDEはそれを認識しません。 Windows Defenderはそのプロパティのどれも見ることができないので、その名前が何であるかわからない。開発者の一人は、ブラウザ固有のウィンドウだと言います。 (それが何であれそれを見ることができないのであれば、それは何であれ、それは何であれ、何であれ)?

誰でもこのアイデアはありますか?私は困惑している。

答えて

0

これはウェブブラウザからのネイティブダイアログです。したがって、これをSeleniumで処理することは容易ではありません。あなたはそれで何をテストしたいですか?これを処理するための最良の方法はSikuliXを使用することです https://sqa.stackexchange.com/questions/2197/how-to-download-a-file-using-seleniums-webdriver

+0

私は基本的には[OK]ボタンをクリックし、Excelドキュメントを開きますので、それを却下します。それは難しいようです。 LOL .... –

1

:いくつかの読書のために

は、また、この質問を参照してください。以下は、SikuliXを使用したシナリオ例です。基本的にSikuliXは、Windows、Mac、Linux/Unixを実行しているデスクトップコンピュータの画面に表示されるものを自動化します。 GUIコンポーネントを識別して制御するために、OpenCVで動く画像認識機能を使用しています。これは、GUIの内部構造や、動作させたいアプリケーションやWebページのソースコードに簡単にアクセスできない場合に便利です。

以下は、hello worldの例です。これは、画面上のスポットライトアイコンをクリックし、スポットライトの入力ウィンドウが表示されるのを待ってから、「hello world」と入力してENTERを押します。

FirefoxProfile profile = new FirefoxProfile(); 
profile.setPreference("pdfjs.disabled", true); // disable the built-in viewer 
profile.setPreference("browser.download.folderList", 2); 
profile.setPreference("browser.download.dir", "C:\\Windows\\temp"); 
profile.setPreference("browser.download.panel.shown", false); 
profile.setPreference("browser.helperApps.neverAsk.openFile", ""); 
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.ms-excel"); 

WebDriver driver = new FirefoxDriver(profile); 
driver.get("http://www.exinfm.com/free_spreadsheets.html"); 
driver.findElement(By.linkText("Capital Budgeting Analysis")).click(); 

または自動でファイルを開くために:あなたは、自動的にフォルダにファイルをダウンロードするには、セットアップのFirefox、sikuli here

0

むしろよりダウンロードウィンドウを処理することができ見つけることができます

import org.sikuli.script.*; 

public class TestSikuli { 

    public static void main(String[] args) { 
      Screen s = new Screen(); 
      try{ 
        s.click("imgs/spotlight.png", 0); 
        s.wait("imgs/spotlight-input.png"); 
        s.type(null, "hello world\n", 0); 
      } 
      catch(FindFailed e){ 
        e.printStackTrace(); 
      } 

    } 

} 

デフォルトアプリケーション:

FirefoxProfile profile = new FirefoxProfile(); 
profile.setPreference("pdfjs.disabled", true); // disable the built-in viewer 
profile.setPreference("browser.download.folderList", 2); 
profile.setPreference("browser.download.panel.shown", false); 
profile.setPreference("browser.helperApps.neverAsk.openFile", "application/vnd.ms-excel"); 
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", ""); 

WebDriver driver = new FirefoxDriver(profile); 
driver.get("http://www.exinfm.com/free_spreadsheets.html"); 
driver.findElement(By.linkText("Capital Budgeting Analysis")).click(); 

注意してくださいあなたのファイルの1つでMIMEタイプ(application/vnd.ms-excel)を更新する必要があります。 MIMEタイプは、応答ヘッダーのContent-Typeです。

そして、あなただけのダイアログを閉じたい場合は、その後、私はのAutoItを使用します。

WinWait("[CLASS:MozillaDialogClass]", "", 10) 
WinClose("[CLASS:MozillaDialogClass]") 
+0

すごくうまくいって、ありがとう! –

関連する問題