FuckTheWorld / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension #816

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Step 1:
Selenium Version: 2.41
OS : Windows 7 Enterprise (64 bit)
Browser: Chrome
Chrome Version: 35.0.1916.114 m

Selenium : 2.41
If i try to capture screen shot using the following method
Method :
public static String captureScreenshot(WebDriver oBrowser)
    {
        File srcFile;
        String dstFileName=System.getProperty("user.dir")+"\\Results\\ErrorScreenShots\\"+System.getProperty("dateTimeVal")+"\\1001_MethodName_"+getDateTime("dd-MMM-yyyy")+"_"+getDateTime("hh-mm-ss")+".png";
        try
        {
            srcFile=((TakesScreenshot) oBrowser).getScreenshotAs(OutputType.FILE);
            FileUtils.copyFile(srcFile, new File(dstFileName));
        } catch(Exception e)
        {
            e.printStackTrace();
        }
        return dstFileName;
    }
 chromedriver displays the following exception

Starting ChromeDriver (v2.9.248315) on port 47313
org.openqa.selenium.WebDriverException: unknown error: cannot get automation 
extension
from unknown error: page could not be found: 
chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.h
tml
  (Session info: chrome=35.0.1916.114)
  (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10.11 seconds
Build info: version: '2.42.0', revision: '5e82430', time: '2014-05-22 20:18:33'
System info: host: 'BLRWCNU3359448', ip: '10.205.50.199', os.name: 'Windows 7', 
os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_40'
Session ID: 46f2d3583dfe52d8754f120315239c7c
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, 
browserName=chrome, 
chrome={userDataDir=C:\Users\pgudi\AppData\Local\Temp\scoped_dir8544_30130}, 
rotatable=false, locationContextEnabled=true, version=35.0.1916.114, 
takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, 
handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, 
webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:596)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:611)
    at org.openqa.selenium.remote.RemoteWebDriver.getScreenshotAs(RemoteWebDriver.java:321)
    at Utility.ApplicationIndependent.captureScreenshot(ApplicationIndependent.java:634)
    at Datatable.Datatable.WriteToResult(Datatable.java:623)
    at Utility.ApplicationDependent.AUT_Login(ApplicationDependent.java:118)
    at Driver.DriverScript.main(DriverScript.java:18)

step 2:

  I have updated the testscript as follows:
ChromeOptions options = new ChromeOptions();
options.addArguments("load-extension=C:\\Users\\pgudi\\AppData\\Local\\Google\\C
hrome\\Application\\35.0.1916.114\\Extensions");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
oBrowser=new ChromeDriver(capabilities);

and in this path 
C:\Users\pgudi\AppData\Local\Google\Chrome\Application\35.0.1916.114\Extensions
I added the following files (Manually)
i.icon.png
ii.manifest.json (this file inturn has the following lines
     {
      "name": "My First Extension",
      "version": "1.0",
      "manifest_version": 2,
      "description": "The first extension that I made.",
      "browser_action": {
       "default_icon": "icon.png"
      },
       "permissions": [
       "https://preview.dentalweb.com"
      ]
      }
iii. external_extensions.json (this file exists bydefault,it has the content as 
follows

// This json file will contain a list of extensions that will be included
// in the installer.

{
}

After performing above settings
I started running the script to capture screen shot,it works inconsistent 
approach some time(in the same package) it captures screen shot and some time 
(other package)it displays the following 
exception

org.openqa.selenium.WebDriverException: disconnected: cannot take screenshot
from disconnected: not connected to DevTools
  (Session info: chrome=35.0.1916.114)
  (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 29 milliseconds
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'BLRWCNU3359448', ip: '10.205.50.199', os.name: 'Windows 7', 
os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_40'
Session ID: ce836198a83eb7174ead50c22125c634
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, 
browserName=chrome, 
chrome={userDataDir=C:\Users\pgudi\AppData\Local\Temp\scoped_dir8740_4372}, 
rotatable=false, locationContextEnabled=true, version=35.0.1916.114, 
takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, 
handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, 
webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:610)
    at org.openqa.selenium.chrome.ChromeDriver.getScreenshotAs(ChromeDriver.java:172)
    at Utility.ApplicationIndependent.captureScreenshot(ApplicationIndependent.java:634)
    at Datatable.Datatable.WriteToResult(Datatable.java:623)
    at Utility.ApplicationIndependent.createAndGetObject(ApplicationIndependent.java:342)
    at Utility.ApplicationIndependent.ifObjectExists(ApplicationIndependent.java:213)
    at Utility.ApplicationDependent.AUT_CloseAlertMessage(ApplicationDependent.java:179)
    at Utility.ApplicationDependent.AUT_Login(ApplicationDependent.java:141)
    at Driver.DriverScript.main(DriverScript.java:20)

Expected: install the Chrome Extensions in consistent approach

Original issue reported on code.google.com by prabhaka...@gmail.com on 5 Jun 2014 at 1:41

GoogleCodeExporter commented 9 years ago
Facing the same issue.. Is this solved?

Thanks,

Original comment by rgr...@gmail.com on 25 Aug 2014 at 3:43

GoogleCodeExporter commented 9 years ago
Any update by now? Thank you.

sbhinge@shipco.com

Original comment by sbhi...@shipcocloud.com on 11 Sep 2014 at 10:11

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hello All,

Have not found any solutions for the error but, we found an appropriate 
solutions for capturing screen shot using java code on windows screen

import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;

public class screen2image
{
public static void main(String[] args) throws Exception
{
    Robot robot = new Robot();
    BufferedImage screenShot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
    ImageIO.write(screenShot, "JPG", new File("D:\\screenShot.jpg"));
}
}

Santosh Bhinge (sbhinge@shipco.com)

Original comment by sbhi...@shipcocloud.com on 22 Sep 2014 at 2:53

GoogleCodeExporter commented 9 years ago
Hi,

the Above solution captures only the windows screen shot (Eclipse) ,it does
not capture the my application (web Page) screen shot during execution of
the Test scripts
Currently i am getting the following exception for the below method
execution, please guide me.

public static String captureScreenshot(WebDriver oBrowser)
{
File srcFile;
String
dstFileName=System.getProperty("user.dir")+"\\Results\\ErrorScreenShots\\"+Syste
m.getProperty("dateTimeVal")+"\\1001_MethodName_"+getDateTime("dd-MMM-yyyy")+"_"
+getDateTime("hh-mm-ss")+".png";
try
{
srcFile=((TakesScreenshot) oBrowser).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(srcFile, new File(dstFileName));
} catch(Exception e)
{
e.printStackTrace();
}
return dstFileName;
}

org.openqa.selenium.WebDriverException: disconnected: cannot take screenshot
from disconnected: not connected to DevTools
  (Session info: chrome=37.0.2062.124)
  (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 x86)
(WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 62 milliseconds
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27
17:17:32'
System info: host: 'Gopal-PC', ip: '192.168.1.16', os.name: 'Windows 7',
os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_40'
Session ID: 4d02d5a4c43f057980f0778c1e701614
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true,
browserName=chrome,
chrome={userDataDir=C:\Users\Gopal\AppData\Local\Temp\scoped_dir5668_3310},
rotatable=false, locationContextEnabled=true, version=37.0.2062.124,
takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false,
handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true,
webStorageEnabled=true, applicationCacheEnabled=false,
takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:
145)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:610)
at
org.openqa.selenium.chrome.ChromeDriver.getScreenshotAs(ChromeDriver.java:172)
at
Utility.ApplicationIndependent.captureScreenshot(ApplicationIndependent.java:652
)
at Datatable.Datatable.WriteToResult(Datatable.java:710)
at
Utility.ApplicationIndependent.clickObject(ApplicationIndependent.java:90)
at
Utility.ApplicationDependent.AUT_AddPatientInfo(ApplicationDependent.java:242)
at
TestScripts.TestScripts.qdw_CreatePatientwithInsurance(TestScripts.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at Driver.DriverScript.main(DriverScript.java:43)

Original comment by prabhaka...@gmail.com on 28 Sep 2014 at 2:55

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 21 Feb 2015 at 12:18

GoogleCodeExporter commented 9 years ago
Unable to reproduce issue in both Windows 7 and in Ubuntu 14.04 with 
chrome:35.0.1916.114, chromedriver:2.9 and 
chrome:41.0.2272.89, chromedriver:2.14

Below is sample code:
public static void main(String[] arg) {
                System.setProperty(""webdriver.chrome.driver"",
                                ""C:\\Java\\libs\\chromedriver.exe"");

                ChromeOptions options = new ChromeOptions();
                options.addArguments(""load-extensions=C:\\Java\\ChromeExtensions"");
                DesiredCapabilities caps = new DesiredCapabilities();
                caps.setCapability(ChromeOptions.CAPABILITY, options);

                WebDriver driver = new ChromeDriver(caps);
                driver.get(""http://www.google.com"");

                System.out.println(""OutputFile: "" + captureScreenshot(driver));

        }

        public static String captureScreenshot(WebDriver oBrowser) {
                File srcFile;
                String dstFileName = System.getProperty(""user.dir"")
                                + ""\\Results\\ErrorScreenShots\\"" + ""\\1001_MethodName.png"";
                try {
                        srcFile = ((TakesScreenshot) oBrowser)
                                        .getScreenshotAs(OutputType.FILE);
                        FileUtils.copyFile(srcFile, new File(dstFileName));
                } catch (Exception e) {
                        e.printStackTrace();
                }
                return dstFileName;
        }

Original comment by ssudunag...@chromium.org on 17 Mar 2015 at 8:23

GoogleCodeExporter commented 9 years ago
I am able to duplicate this problem at will using ruby with chromedriver. 

Ruby 2.0.0-P598
Selenium 2.44.0
ChromeDriver 2.14.313457

using Atomshell to launch an html 5 application.  Attaching capybara to it, and 
executing

Capybara.save_screenshot('test.jpg')

Throws the exception:

Selenium::WebDriver::Error::UnknownError: unknown error: cannot get automation 
extension
from unknown error: page could not be found: 
chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.h
tml
  (Session info: chrome=40.0.2214.91)
  (Driver info: chromedriver=2.14.313457 (3d645c400edf2e2c500566c9aa096063e707c9cf),platform=Mac OS X 10.10.2 x86_64)
from 
/Users/brian.carlson/.rvm/gems/ruby-2.0.0-p598@acorn/gems/selenium-webdriver-2.4
4.0/lib/selenium/webdriver/remote/response.rb:52:in `assert_ok'

Original comment by Brian.Mi...@gmail.com on 24 Mar 2015 at 4:26

GoogleCodeExporter commented 9 years ago
please share your script 

Original comment by ssudunag...@chromium.org on 25 Mar 2015 at 5:57

GoogleCodeExporter commented 9 years ago

Original comment by ssudunag...@chromium.org on 26 Mar 2015 at 6:35

GoogleCodeExporter commented 9 years ago
env setup for driver:
Capybara.register_driver :atom do |app|
    # Assume local setup
    caps = Selenium::WebDriver::Remote::Capabilities.chrome(
      "chromeOptions" => {"binary" => atom_binary_path}

    options = {
      browser: :chrome,
      desired_capabilities: caps
    }
    Capybara::Selenium::Driver.new(app, options)
  end
end

Capybara.configure do |capybara|
  capybara.default_wait_time = 20
  capybara.default_driver    = :atom
  capybara.exact             = true
end

Login method:
    def login!()
      fill_in('username', with: 'johndoe')
      fill_in('password', with: 'something')

      Capybara.save_screenshot('/path/login_page.jpg')
      click_button("Login")
    end

Original comment by Brian.Mi...@gmail.com on 31 Mar 2015 at 8:49

GoogleCodeExporter commented 9 years ago
prabhakargudi / Brian.Michael.Carlson

please try with latest versions of chromedriver:2.15 and chrome:v43 and let us 
know if you still see the issue.

Original comment by ssudunag...@chromium.org on 25 May 2015 at 9:08

GoogleCodeExporter commented 9 years ago
We have faced some issue with chrome browser it's got resolved after deleting 
unwanted extension(ref Screenshot).

Original comment by pmahendr...@gmail.com on 24 Jun 2015 at 6:28

Attachments:

GoogleCodeExporter commented 9 years ago
Brian.Michael.Carlson@

Ran below sample ruby code without capybara and able to capture screenshot 
successfully.

Please try without Capybara and let us know if you still facing issue with 
latest chromedriver:2.16

Sample Code:
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome
driver.navigate.to 'http://www.google.com'
driver.save_screenshot('google.png')
driver.close

Original comment by ssudunag...@chromium.org on 17 Jul 2015 at 10:31

oliaLi commented 7 years ago

I am facing the same issue using python: WebDriverException: Message: unknown error: cannot get automation extension E from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html

Tom331 commented 7 years ago

I am getting the same error as @oliaLi but I am using protractor with selenium-webdriver. But I am not trying to take a screenshot, the error occurs for me whenever I use browser.manage()

misscielo commented 7 years ago

Hi, im having the same problem too.. here's my issue:

https://github.com/FuckTheWorld/chromedriver/issues/1156