Using ChromeDriver

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Using ChromeDriver

Postby mkoubaa » Mon Jul 27, 2015 1:44 pm

Hello,

I tried the sample in https://bitbucket.org/chromiumembedded/ ... romeDriver and it works great.

Unfortunately the approach in this file may not be appropriate for my CEF application (e.g. MyCef.exe). MyCef.exe is a windows application that already has a testing harness and many tests. CEF makes up one piece of this application, and I need to write an API that can be invoked from my existing test harness to automate CEF.

1. The example launches cefclient.exe. I need to access an already running MyCef.exe, and automate the browser on there.
2. MyCef.exe has multiple cef browser instances, it is not clear how ChromeDriver picks it in the example.
3. The remote debugging port command line argument and CefSettings values must be empty for the example to work. Why is this?
4. Is it possible to use chrome and localhost:Nnnnn with the remote debugging port to automate the page? This seems like its what I'm after..

Thanks in advance,
Mohamed
mkoubaa
Techie
 
Posts: 24
Joined: Mon Dec 29, 2014 4:28 pm

Re: Using ChromeDriver

Postby mkoubaa » Mon Jul 27, 2015 4:48 pm

I figure I can use the DOM to get elements and create mouse events, so long as I can somehow programatically access the console of the remote debugging page from WebDriver, I can do what I'm after. Even if this somehow works, its still a pain..

System.setProperty("webdriver.chrome.driver", "E:\\ChromeDriver\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("localhost:60985"); //The remote debugging port of my host application
sleep(1000); // Let the page load
WebElement test_page = driver.findElement(By.linkText("PageToTest.htm")); //Pick from the list of available pages
test_page.click(); //Open devtools

WebElement console_window = ????????????????????????
console_window.sendKeys("var _event = new MouseEvent('click', { 'view': window, 'bubbles': true, 'cancelable': true });");
console_window.submit();
console_window.sendKeys("var test_button = document.getElementById('test_button');");
console_window.submit();
console_window.sendKeys("test_button.dispatchEvent(_event);");
console_window.submit();
sleep(3000);
driver.quit();
mkoubaa
Techie
 
Posts: 24
Joined: Mon Dec 29, 2014 4:28 pm

Re: Using ChromeDriver

Postby mkoubaa » Tue Jul 28, 2015 4:29 pm

I have one other idea for how to do this. Provide an API to the existing test harness to execute javascript on the browser. Then the test harness client, aka the tester, can write several lines of javascript commands and then send them into that API call. I think I will go with this unless someone can think of an easier way.

To facilitate this I figured that using webdriverJS on the browser would make the tester's job easier (instead of having to use DOM code directly).
I tried compiling WebDriver.js from selenium, and including it in my page. In order to make it work though, as per https://code.google.com/p/selenium/wiki ... _a_Browser I need to supply a session Id and server url via 'environment variables' on the url. I know how to get the server url (using localhost and the remote debugging port number), but I have no clue how to get the session ID. Does anyone know how to access the sessionId from cef?

Thanks!
mkoubaa
Techie
 
Posts: 24
Joined: Mon Dec 29, 2014 4:28 pm

Re: Using ChromeDriver

Postby Anima » Fri Nov 17, 2017 10:20 am

Finding myself with similar problems. I don't suppose you found a decent solution?
Anima
Newbie
 
Posts: 8
Joined: Wed Aug 02, 2017 9:06 am

Re: Using ChromeDriver

Postby Anima » Fri Nov 17, 2017 11:40 am

Actually, you can connect to an existing Chrome/CEF by just setting the DebuggerAddress of the ChromeDriver Options.
Anima
Newbie
 
Posts: 8
Joined: Wed Aug 02, 2017 9:06 am

Re: Using ChromeDriver

Postby payalord » Mon Jan 22, 2018 3:29 pm

mkoubaa wrote:I have one other idea for how to do this. Provide an API to the existing test harness to execute javascript on the browser. Then the test harness client, aka the tester, can write several lines of javascript commands and then send them into that API call. I think I will go with this unless someone can think of an easier way.

To facilitate this I figured that using webdriverJS on the browser would make the tester's job easier (instead of having to use DOM code directly).
I tried compiling WebDriver.js from selenium, and including it in my page. In order to make it work though, as per https://code.google.com/p/selenium/wiki ... _a_Browser I need to supply a session Id and server url via 'environment variables' on the url. I know how to get the server url (using localhost and the remote debugging port number), but I have no clue how to get the session ID. Does anyone know how to access the sessionId from cef?

Thanks!


"Session" usually is the thing that handled by server and server stores it's id in cookies, but each server can store id in their own cookie variable/name. So in which exactly cookie it is stored depends on server. So I don't think there is some kind of session id rather than server provided in cookies - exists and you need it. Or i just got it wrong.
payalord
Techie
 
Posts: 21
Joined: Sun Jan 07, 2018 8:21 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 44 guests