1

내가 실패한 테스트 케이스의 스크린 샷을하려고하지만, 자동화 확장과 관련된 오류가 점점 오전 :수 없습니다

public static String captureScreenshot(WebDriver driver, String screenshotName) 
{ 
try 
{ 
    TakesScreenshot ts = (TakesScreenshot)driver; 
    File source = ts.getScreenshotAs(OutputType.FILE); 
    String userDirector = System.getProperty("user.dir"); 
    String resultFile = userDirector 
      + "\\src\\main\\java\\utils\\screenshots\\"+screenshotName+".png"; 
    File destination = new File(resultFile); 
    FileUtils.copyFile(source, destination); 
    System.out.println("Screenshot Taken"); 
    return resultFile; 

} 
catch(Exception e) 
{ 
    System.out.println("Exception while taking screenshot" + e.getMessage()); 
    return e.getMessage(); 

} 

를이 내가이 메서드를 호출하고 내 클래스 나는 또한 B를 시도

TestCases failed and TestScript is KeepCookiesCheckInvalidScenario 
Exception while taking screenshotunknown error: cannot get automation 
extension 


from unknown error: page could not be found: chrome- 


extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html 
(Session info: chrome=60.0.3112.113) 
(Driver info: chromedriver=2.27.440174 
(e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 10.0.14393 
    x86_64) (WARNING: The server did not provide any stacktrace information) 
    Command duration or timeout: 10.20 seconds 

:

@AfterMethod (alwaysRun = true) 
public void tearDown(ITestResult result) throws InterruptedException, IOException{ 
    if (result.getStatus()==ITestResult.FAILURE){ 
     String screenshot_path=Screenshot.captureScreenshot(driver, result.getName()); 
     String image = logger.addScreenCapture(screenshot_path); 
     logger.log(LogStatus.FAIL, "Test Script Failed and TestScript name is ", image); 
     Thread.sleep(3000); 

    } 
     report.endTest(logger); 
     report.flush(); 
    //else if ((result.getStatus()== ITestResult.SUCCESS)){ 
    // logger.log(LogStatus.PASS, "test case Pass1" + result.getName()); 
    //} 
    //TestBase.updateResult(1, "result.getName()", "Pass", "I dont Know"); 

    driver.close(); 
} 

이를 실행 한 후 나는 다음과 같은 오류를 얻고있다 Y는 여기에 드라이버를 폐쇄하지,하지만 당신이 다음 크롬 속성에 대한 코드 아래 시도 크롬을 사용하는 경우

+0

chromedriver를 업데이트 하시겠습니까? –

답변

0

도와주세요, 작동하지 않는 :

System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe"); 
ChromeOptions options = new ChromeOptions(); 
options.addArguments("test-type"); 
options.addArguments("start-maximized"); 
options.addArguments("--enable-automation"); 
options.addArguments("test-type=browser"); 
options.addArguments("disable-infobars"); 
WebDriver driver = new ChromeDriver(options); 

을 내가 위에서 사용하여 문제를 해결할 수있을 것입니다 희망 코드. 즐겨 !