Selenium を使用してページに移動し、Internet Explorer を使用してスクリーンショットを撮っています。しかし問題は、ログインが Javascript アラート ボックスによって処理されることです。現在、Selenium には、Alert 要素を使用してアラート ボックスにフォーカスを移動できる機能があり、フォーカスを移動して、ユーザー名のテキスト ボックスにいくつかの値を入力することもできました。
問題は、Selenium がフォーカスをパスワード テキスト ボックスに切り替えず、同じボックスにユーザー名とパスワードを入力することです。Java AWT Robot でタブ キーをクリックしてフォーカスを変更しようとしましたが、Selenium はこれを認識せず、同じボックスにユーザー名とパスワードを入力し続けます。
以下は私のコードです:
Robot robot = new Robot();
driver.get("the url");
Alert alert = driver.switchTo().alert();
alert.sendKeys("username");
robot.keyPress(KeyEvent.VK_TAB);
alert.sendKeys("password");
alert.accept();
ここで何が欠けていますか?ここでの私のアプローチは正しいですか、それとも別のルートをたどる必要がありますか?