kryskool / cefpython

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

automate cefpython #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello!
How can I automate the filling of the search string (for example google.com) 
using cefpython?

Original issue reported on code.google.com by ArtemKra...@gmail.com on 9 Nov 2012 at 6:03

GoogleCodeExporter commented 9 years ago
You can execute arbitrary javascript on webpages, use 
Browser->GetMainFrame()->ExecuteJavascript("document.getElementById('lst-ib').va
lue='my search';")

Original comment by czarek.t...@gmail.com on 9 Nov 2012 at 3:13

GoogleCodeExporter commented 9 years ago

Original comment by czarek.t...@gmail.com on 9 Nov 2012 at 3:14

GoogleCodeExporter commented 9 years ago
could you show on this example:
# An example of embedding CEF in wxPython application.
#coding:utf-8

import wx
import sys
import time
import cefpython

# TODO: currently we use wx.Timer to imitate message loop, but
# it would probably be better to use wx.CallLater() and wx.lib.pubsub.

class MainFrame(wx.Frame):

    browser = None

    def __init__(self):

        wx.Frame.__init__(self, parent=None, id=wx.ID_ANY, title='wxPython example', size=(1000,800))
        self.CreateMenu()
        self.browser = cefpython.CreateBrowser(self.GetHandle(), browserSettings={}, navigateURL="http://google.com")       

        self.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus)
        self.Bind(wx.EVT_SIZE, self.OnSize)

    def CreateMenu(self):

        filemenu = wx.Menu()
        filemenu.Append(1, "Открыть")
        filemenu.Append(2, "Выход")

        aboutmenu = wx.Menu()
        aboutmenu.Append(1, "CEF Python")

        menubar = wx.MenuBar()
        menubar.Append(filemenu,"&File")
        menubar.Append(aboutmenu, "&About")

        self.SetMenuBar(menubar)

    def OnSetFocus(self, event):

        cefpython.wm_SetFocus(self.GetHandle(), 0, 0, 0)

    def OnSize(self, event):

        cefpython.wm_Size(self.GetHandle(), 0, 0, 0)

class MyApp(wx.App):

    timer = None
    timerID = 1

    def OnInit(self):

        cefpython.Initialize()
        sys.excepthook = cefpython.ExceptHook

        self.timer = wx.Timer(self, self.timerID)
        self.timer.Start(10) # 10ms
        wx.EVT_TIMER(self, self.timerID, self.OnTimer)

        frame = MainFrame()
        self.SetTopWindow(frame)
        frame.Show()

        return True

    def OnExit(self):

        self.timer.Stop()
        cefpython.Shutdown()

    def OnTimer(self, event):

        cefpython.SingleMessageLoop()

if __name__ == '__main__':

    print('wx.version=%s' % wx.version())
    app = MyApp(False)
    app.MainLoop()

print list(sys.modules.keys())

Original comment by ArtemKra...@gmail.com on 12 Nov 2012 at 6:58

GoogleCodeExporter commented 9 years ago
This is an issue tracker where you report bugs or feature requests, this is not 
a help forum.

Original comment by czarek.t...@gmail.com on 13 Nov 2012 at 12:27