Forum Discussion

xyin's avatar
xyin
Occasional Contributor
10 years ago
Solved

Help or sample on CEF3 automation?

Hello,

 

I need to automate our CEF3 based application but could not find a tutorial or sample of TC, neither could I find an example in the forums (please kindly point me to one if I missed any).

 

So I just followed the sample on web automation and tried on my own (according to the help file, CEF test will be done using the Web plug-in of TC).

 

I downloaded a CEF3 client built by Marshal Greenblatt (owner and contributor of the CEF project, see: https://code.google.com/p/chromiumembedded/). He built a sample CEF3 client that can be downloaded from:  http://www.magpcss.net/, the zipped file is “cef_binary_3.2171.1979_windows32_client.7z”.

 

The TC’s help file states:

 

When you launch a generic Windows application during test recording, TestComplete can automatically add that application to the Tested Applications collection of your project.

and

In order to expose a CEF-based application, you need to add it to the Tested Applications collection and then launch it in Simple run mode, while one of the following conditions is met:

The application's executable imports the libcef.dll library.

-- or --

The libcef.dll library and the application's executable are located in the same folder.

-- or --

The application has the injectCefHook command-line argument (in any letter case and with any prefix)

 

I checked the unzipped CEF client directory and found that the application executable and the libcef.dll file are in the same folder.

 

So I think I just need to record a simple test and then should be able to repeat the test.

Here’s what I did:

  • Created a new project named “cef_mg_search”, with “Functional testing of web pages” and VBScript.
  • Started recording: record script.
  • Opened the CEF client (its default home is Google), entered “testcomplete”, clicked on the first found result (TC’s home page), clicked on “Features”, then closed the CEF client.
  • Stopped recording.
  • Saved project (and it appears the CEF application has been added under TestedApps).
  • Tried to run the recorded test case.

However the test failed to finish. It was only able to launch the CEF client, but failed to enter the text into the searching field.

 

Then I tried to use the Object Spy on the CEF client, and it seems it could NOT recognize the objects such as the input text field and the buttons (“Google Search”, “I’m feeling lucky”).

 

See screenshots at the end.

 

Can someone help me with this?

It would be great if you could include a sample test case using the above CEF client, also using VBScript, and with descriptive programming (since I don’t want to use local object repository).

 

Thank you.

 

 

 11.jpg

 22.jpg

 

33.jpg

  • Launch CEF application from TestedApps before any usage. Only TC11.30 supports CefSharp.WPF applications.

6 Replies

  • drnie007's avatar
    drnie007
    New Contributor

    Dear xyin,

     

    I did the same with another minimal example application, you can find here:

     

    https://github.com/cefsharp/CefSharp.MinimalExample

     

    * the application executable and the libcef.dll file are in the same folder

     

    * launching the application out of TestComplete in simple run mode

     

    The result was the same, Object Spy was not able to recognize any object in the application and the recording result provides only Click(X,Y) elements.

     

    Did you made any progress?

     

    Is there anybody who can help?

     

    Regards,

     

    Guido

    • xyin's avatar
      xyin
      Occasional Contributor

      Hi Guido,

       

      I'm using TC11 now and it works with my CEF application and with the sample one I mentioned in the posting.

       

      I was going to try your application but after I downloaded the zip file and extracted it I could not find the executable file.

      How do you launch your CEF application?

       

      Xuemin

      • drnie007's avatar
        drnie007
        New Contributor

        Dear Xuemin,

         

        thank you for tihs informative response.

         

        I am already using TestComplete 11.20. To get the executable you need to compile the sample.

         

        You can do this as follows:

         

        1. Install Visual Studio 2012

        2. Open Visual Studio and do

         

        FILE -> Open Project/Solution

         

        go to the extracted source directory and open "CefSharp.MinimalExample.sln"

         

        3. Then do

         

        BUILD -> Clean solution

        BUILD -> Build solution

         

        4. To start the executables do

         

        cd <somwhere in the directory>\CefSharp.MinimalExample-master\CefSharp.MinimalExample.WinForms\bin\x64\Debug

         

        and execute CefSharp.MinimalExample.WinForms.exe

         

         

        Unfortunately it does not show the expected behaviour, that you can see detailed object tree in the object browser. Object Spy does not work and if you start a recording, you will get a result for example as follows:

         

        function Test3()
        {
        var chromiumWebBrowser;
        chromiumWebBrowser = Aliases.CefSharp_MinimalExample_Wpf.HwndSource_MainWindow.MainWindow.Grid.Browser;
        chromiumWebBrowser.Click(1097, 340);
        chromiumWebBrowser.Keys("Hello World[Enter]");
        }

        function Test4()
        {
        var browserForm;
        var chrome_WidgetWin_0;
        browserForm = Aliases.CefSharp_MinimalExample_WinForms.BrowserForm;
        browserForm.Click(866, 15);
        chrome_WidgetWin_0 = browserForm.toolStripContainer.ToolStripContentPanel.ChromiumWebBrowser.CefBrowserWindow.Chrome_WidgetWin_0;
        chrome_WidgetWin_0.Chrome_RenderWidgetHostHWND.Click(1034, 339);
        chrome_WidgetWin_0.Keys("Hello World[Enter]");
        }

        function Test5()
        {
        var browserForm;
        var toolStripContainer;
        var toolStrip;
        var chrome_RenderWidgetHostHWND;
        browserForm = Aliases.CefSharp_MinimalExample_WinForms.BrowserForm;
        browserForm.Click(433, 17);
        toolStripContainer = browserForm.toolStripContainer;
        toolStrip = toolStripContainer.ToolStripPanel.toolStrip1;
        toolStrip.ClickItem("Back");
        chrome_RenderWidgetHostHWND = toolStripContainer.ToolStripContentPanel.ChromiumWebBrowser.CefBrowserWindow.Chrome_WidgetWin_0.Chrome_RenderWidgetHostHWND;
        chrome_RenderWidgetHostHWND.Click(1288, 249);
        chrome_RenderWidgetHostHWND.Click(1288, 249);
        chrome_RenderWidgetHostHWND.Click(1238, 406);
        chrome_RenderWidgetHostHWND.Click(1238, 406);
        chrome_RenderWidgetHostHWND.Click(1317, 409);
        chrome_RenderWidgetHostHWND.Click(1318, 409);
        toolStrip.ClickItem("Back");
        }

        function Test6()
        {
        var cefSharp_MinimalExample_WinForms;
        var toolStripContainer;
        var chrome_WidgetWin_0;
        var chrome_RenderWidgetHostHWND;
        var toolStrip;
        cefSharp_MinimalExample_WinForms = Aliases.CefSharp_MinimalExample_WinForms;
        toolStripContainer = cefSharp_MinimalExample_WinForms.BrowserForm.toolStripContainer;
        chrome_WidgetWin_0 = toolStripContainer.ToolStripContentPanel.ChromiumWebBrowser.CefBrowserWindow.Chrome_WidgetWin_0;
        chrome_RenderWidgetHostHWND = chrome_WidgetWin_0.Chrome_RenderWidgetHostHWND;
        chrome_RenderWidgetHostHWND.Click(1361, 463);
        chrome_RenderWidgetHostHWND.Click(1354, 463);
        chrome_RenderWidgetHostHWND.Click(1330, 407);
        toolStrip = toolStripContainer.ToolStripPanel.toolStrip1;
        toolStrip.ClickItem("Back");
        toolStrip.ClickItem("Back");
        toolStrip.ClickItem("Forward");
        chrome_RenderWidgetHostHWND.Click(1774, 28);
        cefSharp_MinimalExample_WinForms.wndChrome_WidgetWin_0.Chrome_RenderWidgetHostHWND.Click(65, 155);
        chrome_RenderWidgetHostHWND.Click(1500, 35);
        chrome_WidgetWin_0.Keys("atom[Enter]");
        }

         

        Perhaps you can reproduce it on your machine.

         

        Thank you for your help.

         

        Regards,

         

        Guido