Translate page using selenium + chrome - google-chrome

Is there a way to initiate translating current page in google chrome using selenium?
This is different from changing preference which translates all pages nor setting -lang as command line argument which changes google chrome's language.
I want to translate page on-demand based on the url.
I am using chromedriver + selenium web driver for c#
Thanks

You can use https://chrome.google.com/webstore/detail/google-translate/aapbdbdomjkkjkaonfhkkikfgjllcleb?hl=en google chrome extension to fulfill your requirement. You can automate this utility using autoit.
To add an extension for chrome driver please refer to this link:
HOW TO CREATE .CRX FILE FROM ALREADY INSTALLED CHROME EXTENSION?
HOW TO ADD AN EXTENSION TO GOOGLE CHROME INSTANCE OF SELENIUM WEBDRIVER?

Related

How to attach debugger in chrome extension along with selenium?

Goal: I want to run an experiment in which I will open a list of websites and want to collect the scripts that are parsed on those websites. The way I plan to do is as follows:
using selenium webdriver I will open each website in chrome.
using chrome.debugger api I will attach a debugger and listen to Debugger.Scriptparsed event.
Problem: When I open a website in a chrome (loaded with my extension ) with selenium, it throws an error that another debugger is also attached to tab. I read here, it states that selenium webdriver is using debugger also. In that case is there a way to use these functions with selenium webdriver for chrome only?
Yes, the webdriver itself is working through the debugging protocol and you cannot use the chrome.debugger API or open the developer tools in the browser that is automated with selenium.

Get Chrome URL using Google Developer API or Chrome Plugin

I am trying to get current active tab URL of the chrome browser (v.35+) in VC++ application. I could succeed to capture the URL using Windows Activity Accessibility (MSAA) but I am trying to get URL using other methods also.
I have tried by WinDDE but current Chrome version 35 doesn't support it. Using WinDDE, I could get URL from IExplore and Firefox.
Is it possible to get URL using Chrome Plugin. ( I don't know how to write it ) or Is there any way to do it.
Also do Google Development APIs have COM library for C++ application like they have GetURL in chrome.extension https://developer.chrome.com/extensions/extension

Chrome Packaged App Access Chrome APIs

I'm interested in writing a Packaged App that can access data about chrome, namely the chrome.windows.onCreated and chrome.windows.onRemoved events. If I try to add a listener to either of these, I get an error in the console:
Uncaught TypeError: Cannot read property 'onRemoved' of undefined
Is there any way around this?
The other answers are correct that this isn't directly possible from a packaged app, but there is a solution that meets your needs: You can write an extension as well as a packaged app and have them communicate with chrome.runtime.sendMessage.
The user will have to install both app and extension, but you can make this easy by directing them to the chrome web store from within your application. You can read about this here: Communicating between a Chrome packaged app and a Chrome extension?
Edit: and as pointed out in a comment on that thread, there is a Chrome App Sample that helps demonstrate this in action: https://github.com/GoogleChrome/chrome-app-samples/tree/master/messaging
The chrome.windows API is a Chrome extension API, not a packaged apps API. It is used by extensions to interact with browser windows.
If you can write your application as an extension, it will be able to use that API. Packaged apps, however, don't have the ability to manipulate other windows besides their own.
One simple typo here: It is chrome.windows.onRemoved not chrome.windows.OnRemoved ;)
Note the lowercase o.

Interacting with firefox using an external program

I am looking for a way to interact with a web page and enter data to certain fields in it using an external program that interact with Firefox (or Chromium) web browser. The best I could find is the console commands for the browser, but they only let you go to a certain URL and not interact with the pages' content. I have also tried looking for some extension to do the job but I could not find any. Any suggestions?
You could create Chrome extension that communicates with your application via Chrome Native Messaging API: https://developer.chrome.com/extensions/messaging.html#native-messaging
Take a look at Selenium and the tools mentioned at Selenium alternatives?.

Can you still create a Chrome packaged app in the browser with manifest 2.0?

All of the examples I've seen show apps launching in their own windows. This may be great an all for chromebook/chrome os, but is there still an option to launch in a browser tab?
No, there is no way to do that. Chrome Packaged Apps are not supposed to run inside a browser. You can, however, open URLs in a browser tab using window.open. But you won't have control of that tab after you issue the command.
If you need some sort of integration/control between your Chrome Packaged App and the browser, you can create an extension and make a communication pipe between the extension and the app - as long as both are running, using the chrome.runtime.sendMessage API.
See this sample for a simple code that does exactly that (two apps and one extension exchanging messages directly, without any server component).
chrome.app.window.create will create a new Window for an App.
If you want window manipulation, you should switch to chrome.tabs API and look for an extension instead of an App.
Reference
chrome.tabs
chrome.app.window