I have to verify some ads displayed on google search. These ads displayed only when I install the extensions for chrome browser. But when I launch chrome browser from WebDriver script it launches the browser without extentions (even though extensions are already installed) to chrome browser.
I have googled but didnt get much information.
I have tried below method but it didnt work out:
DesiredCapabilities capability = DesiredCapabilities.chrome();
System.setProperty("webdriver.chrome.driver", "libs\\chromedriver.exe");
capability.setCapability("chrome.switches", Arrays.asList("--load-extension=C:\\Users\\ashfaq.md\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Extensions"));
Please help me to resolve this issue.
You can learn how to install Chrome Extensions via ChromeDriver here:
https://sites.google.com/a/chromium.org/chromedriver/extensions
Though not tested on own end... Please check the following:
ChromeOptions options = new ChromeOptions()
options.addExtensions(new File("/path/to/extension.crx"))
options.setBinary(new File("/path/to/chrome"));
// For use with ChromeDriver:
ChromeDriver driver = new ChromeDriver(options);
// or alternatively:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
ChromeDriver driver = new ChromeDriver(capabilities);
// For use with RemoteWebDriver:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
RemoteWebDriver driver = new RemoteWebDriver(
new URL("http://localhost:4444/wd/hub"), capabilities);
Related
I am using chrome_options.add_extension to add the extension into chrome browser and it works fine but the extension is loading in switch off mode. How can i handle that in script.
chrome_options = ChromeOptions()
chrome_options.add_extension(ExtensionPath)
driver = webdriver.Chrome(Chromepath, options=chrome_options)
First up, I'm fairly new to .NET and C# and this is a project to learn C# and CEF at the same time.
I have followed a number of tutorials from the net as well as looking into the CefSharp examples to create a WinForms application.
I have installed CefSharp.WinForms 53.0.1 from NuGet, and my project is using Any CPU (CefSharp 51+ has Any CPU support).
To achieve this I largely followed the tutorial from Ourcode (http://ourcodeworld.com/articles/read/173/how-to-use-cefsharp-chromium-embedded-framework-csharp-in-a-winforms-application). I made the changes for Any CPU as suggested and included the basic code to load google.
Everything builds fine, but when the form displays there's no browser shown, just a blank form.
If I set the target to x64 or x86, then the browser displays as expected.
I notice in the Ourcode comments that user Edek Halon has had the same issue, but no solution seems to be provided. Edek, has the same setup as me, so I wonder if this is an issue in 53.0.1? Potentialy Joey De Vries in the comments has the same issue.
The addition of support for Any CPU in CefSharp is covered in this GitHub issue : https://github.com/cefsharp/CefSharp/issues/1714
There is a troubleshooting page for CefSharp (https://github.com/cefsharp/CefSharp/wiki/Trouble-Shooting) and it seems a bit contradictory. Under General Troubleshooting
1) Platform Target You must select either x86 or x64 when using the NuGet packages. If you select AnyCPU the NuGet magic won't work currently.
Does CefSharp need to be built from source for Any CPU to work?
Just if anyone is having difficulties with this, follow the Github Tutorial at the following link : https://github.com/cefsharp/CefSharp/issues/1714
Basically the code should be as follows (Winforms Example):
CefSharpSettings.SubprocessExitIfParentProcessClosed = true;
Cef.EnableHighDPISupport();
CefSettings settings = new CefSettings
{
CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache"), //By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
BrowserSubprocessPath = #"x86\CefSharp.BrowserSubprocess.exe"
};
Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null); // Initialize cef with the provided settings
chromeBrowser = new ChromiumWebBrowser("http://ourcodeworld.com"); // Create a browser component
this.Controls.Add(chromeBrowser); // Add it to the form and fill it to the form window.
chromeBrowser.Dock = DockStyle.Fill;
Using the latest jar of webdriver java(2.33), trying to set implicit wait but the timeouts() is not available in available options for driver.manage() in Eclipse.
It throws an error that this is not an available option for this class. Tried the same with 2.30 and same issue was repeating. Has any one seen such issue, please let me know on how this can be handled?
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
I got the problem. I was migrating scripts from RC to WebDriver and included both RC and Webdriver Java jars in the build path. Once i removed the RC files, it started working fine.
Thanks Arran, HemChe for atleast responding. Some ignorant fellow has rated my post -1 rating.
OK I know that in Adobe Air you can call navigateToURL(new URLRequest(url)) and it will open the users default web browser to open the page.
Also now in AIR 2 you can launch any application.
So I am wondering if there is a way I can launch a particular browser to open a page in?
I it turns out with AIR 2 you can run command ling arguments so I was able to achieve what I wanted like so:
private function openApp():void
{
if(NativeProcess.isSupported)
{
var file:File = File.userDirectory;
file = file.resolvePath("AppData/Local/Google/Chrome/Application/chrome.exe");
var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
nativeProcessStartupInfo.executable = file;
var process:NativeProcess = new NativeProcess();
var args:Vector.<String> = new Vector.<String>();
args.push("https://www.google.com");
nativeProcessStartupInfo.arguments = args;
process.start(nativeProcessStartupInfo);
}
}
If you're using navigateToURL it, basically, passes the URL to the operating system and opens the default application for handling such requests. You can use navigateToURL to open word documents and other files too.
I was pretty sure that the NativeProcess features of AIR 2 allow you to launch applications, but I did not believe they allow you introspect the system to discover what browsers exist and where the DLL / EXE files are.
A good article on the native process stuff: http://www.adobe.com/devnet/air/flex/quickstart/interacting_with_native_process_02.html
We have an advanced webpage (ASP.NET, C#), and a application which needs to be installed on the client computer in order to utilize the webpage to its fullest. The application is a tray app, and has primarily two tasks. Detect when certain events happen on the webserver (for instance invited to a meeting, or notify of an upcoming meeting). The other task the trayapp has is to use a custom protocol (trayapp://) to perform some ajax calls back to the server.
One problem we have is how to determine if the application is installed on the local machine or not. Now the user has to tick a checkbox to inform the website that the application is installed, and that it's safe to call the trayapp:// url calls.
Is there any way, for instance through a JavaScript or similar to detect if our application is installed on the local machine?
The check needs to work for IE, FF and Opera browsers.
When installing your client-side app you could modify the browser configuration to include another request header in HTTP requests and then have the server code look for that header, for example as a supported mime type using the following registry key (for Internet explorer)
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\
Internet Settings\Accepted Documents
I am not sure if Opera and FF use this same key, but they likely have similar configuration options, but this should at least get you on the right track.
If you want to detect with javascript inside the browser, you can probably use the collection "navigator.plugins". It works with Firefox, Opera and Chrome but unfortunately not with IE.
Update:
In FF, Opera and Chrome you can test it easily like this:
if (navigator.plugins["Adobe Acrobat"]) {
// do some stuff if it is installed
} else {
// do some other stuff if its not installed
}
Update #2:
If it is an ActiveX object in IE you can test if it exists by using something like this:
function getActiveXObject(name){
try{
return new ActiveXObject(name);
}
catch(err){
return undefined;
}
};
Another approach for IE is something similar to what JohnFx suggested (I found it here and have not tested it):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Internet
Settings\User Agent\Post Platform
Good idea from #JohnFx.
Another way to tackle this would be to install an ActiveX control or Browser plug-in with the trayapp installation. You could then access this in a similar way to that done when checking the version of Flash available.
Expose the trayapp (assuming this as a Managed app) as COM object. You could then use the tag with the GUID and trap errors when not found or use the ActiveXobject with the progid to detect if it's installed.