selenium:webdriberが一瞬で閉じてしまう

エラーを解消したい

webdriverが一瞬で閉じてしまうのを解消したい

前提

eclipseのjavaにてテスト受動の為seleniumを利用しています。
junitで実行時にwebdriverが一瞬起動されるのですが、すぐに閉じてしまいます。
2023/03時点では使用できていたのですが、久しぶりに起動したら上記事象が発生しました。
プエログラム未経験で、自分でも理解出来ていない点が多々ありますので、不足情報などございましたら教えていただけますと幸いです。

発生している問題・エラーメッセージ

SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
Starting Microsoft Edge WebDriver 111.0.1661.51 (5b30e0e79e572b7d6873934eb1b328c220c72c9b) on port 39124
To submit feedback, report a bug, or suggest new features, please visit https://github.com/MicrosoftEdge/EdgeWebDriver

Only local connections are allowed.
Please see https://aka.ms/WebDriverSecurity for suggestions on keeping Microsoft Edge WebDriver safe.

Microsoft Edge WebDriver was started successfully.

エラーメッセージ

### 該当のソースコード package sample; import java.io.File; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import util.TestUtils; public class Sample1 { private WebDriver driver; String className = new Object(){}.getClass().getEnclosingClass().getSimpleName(); private String path = TestUtils.getPath() + className + "\\"; /** * 事前処理 * @throws Exception */ @Before public void setUp() throws Exception { driver = TestUtils.setUp(); } /** * 後処理 * @throws Exception */ @After public void tearDown() throws Exception { TestUtils.tearDown(); } /** * ログイン画面の表示内容確認 * 試験実施 * @throws InterruptedException */ @Test public void IT01_01_001() throws InterruptedException { //自メソッド名の取得 final String methodName = new Object() { }.getClass().getEnclosingMethod().getName(); //テスト開始のコメント表示 System.out.println(methodName + "を開始します。"); try { //エビデンス格納ディレクトリ作成 TestUtils.mkdir(path + File.separator + methodName, "キャプチャ"); ////////////// //試験実施 ////////////// //テスト内容 //ログインユーザ String user = "userid"; //ログインパスワード String passwd = "password"; //ログイン //HTMLのタグは調整してください driver.findElement(By.id("userName")).sendKeys(user); driver.findElement(By.id("password")).sendKeys(passwd); driver.findElement(By.id("toHome")).click(); Thread.sleep(5000); //キャプチャ TestUtils.screenShot(this.driver, path + methodName + File.separator +"キャプチャ", "001"); ////////////// //後処理 ////////////// } catch (Exception e) { System.out.println(e); } //テスト終了のコメント表示 System.out.println( methodName+ "を終了します。"); } } ```ここに言語名を入力 ソースコード package sample; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.time.Duration; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; import org.openqa.selenium.edge.EdgeDriver; import org.openqa.selenium.remote.Augmenter; public class TestUtils { private static WebDriver driver; //最初に表示する画面のURLを設定する private static String url = "最初に表示する画面のURL"; /** * ブラウザを起動し、urlの画面を表示する * @return */ public static WebDriver setUp() { System.setProperty("webdriver.edge.driver", "exe/msedgedriver.exe"); driver = new EdgeDriver(); driver.get(url); //ウインドウサイズを最大にする driver.manage().window().maximize(); return driver; } /** * ブラウザを閉じる */ public static void tearDown() { driver.close(); } /** * エビデンス格納先のパス(共通部分) * @return */ public static String getPath() { String path = "C:\\selenium\\evidence\\"; return path; } /** * キャプチャ用のフォルダを指定の場所に作成 * * @param dirpath * @param dirname * @return * @throws IOException */ public static String mkdir(String dirpath, String dirname) throws IOException { String path = Paths.get(dirpath, dirname).toString(); if (Files.notExists(Paths.get(dirpath, dirname))) { Files.createDirectories(Paths.get(dirpath, dirname)); } return path; } /** * 表示部分をスクリーンショット * * @param driver * @param path スクリーンショットを保存するファイルパス名 * @param filename 画像ファイル名 * @throws IOException */ public static void screenShot(WebDriver driver, String path, String filename) throws IOException { driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(30)); driver.switchTo().defaultContent(); TakesScreenshot ts = (TakesScreenshot) new Augmenter().augment(driver); Path from = Paths.get(ts.getScreenshotAs(OutputType.FILE).toURI()); Path to = Paths.get(path + "\\" + filename + ".png"); Files.move(from, to, StandardCopyOption.REPLACE_EXISTING); } } ### 試したこと exeファイル自体が起動しなかったため、ipv6の競合と考察しオフにしました。 結果としてexeファイルは起動可能、eclipse上では変化は見られませんでした。 ここに問題に対して試したことを記載してください。 ### 補足情報(FW/ツールのバージョンなど) edge バージョン 113.0.1774.57 selenium 2022 ここにより詳細な情報を記載してください。

コメントを投稿

0 コメント