Has anyone managed to launch a selenium cef, using python?

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

Has anyone managed to launch a selenium cef, using python?

Postby tzahisofer » Sun Nov 17, 2019 8:34 am

Hi,
I have tried to set up a selenium test for a cef app (cefsimple.exe), using python. I have followed the famous Java example from https://bitbucket.org/chromiumembedded/cef/wiki/UsingChromeDriver.md, with adaptation to python (setBinary -> binary_loaction), but this does not seem to work (I actually doubted that it will, but I see no other option).

The error I get is 'str object is not callable' which implies that the binary I set is not what the driver expects.

any idea?

Tnx
tzahisofer
Newbie
 
Posts: 8
Joined: Fri Nov 15, 2019 5:31 am

Re: Has anyone managed to launch a selenium cef, using pytho

Postby magreenblatt » Sun Nov 17, 2019 3:14 pm

I would suggest searching for a selenium python tutorial. Test that it works with Google Chrome. It should then be possible to replace the chrome executable with cefclient/cefsimple in the same example.
magreenblatt
Site Admin
 
Posts: 9837
Joined: Fri May 29, 2009 6:57 pm

Re: Has anyone managed to launch a selenium cef, using pytho

Postby tzahisofer » Sun Nov 17, 2019 3:57 pm

Well, I did search but couldn't find one...I have significant expereience with Selenium via python bindings, but couldn't make it work with the cef exe.
tzahisofer
Newbie
 
Posts: 8
Joined: Fri Nov 15, 2019 5:31 am

Re: Has anyone managed to launch a selenium cef, using pytho

Postby magreenblatt » Sun Nov 17, 2019 4:05 pm

Does it work with Google Chrome? What does that code look like?
magreenblatt
Site Admin
 
Posts: 9837
Joined: Fri May 29, 2009 6:57 pm

Re: Has anyone managed to launch a selenium cef, using pytho

Postby tzahisofer » Sun Nov 17, 2019 4:58 pm

It does.
Simple example:

def initializeDriver():
chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location("C:\work\cefsimple.exe")
chrome_options.add_argument('--remote-debugging-port=12345')
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.implicitly_wait(0.5)
return driver
driver = initializeDriver()

And it fails on the 'binary_location' line.
tzahisofer
Newbie
 
Posts: 8
Joined: Fri Nov 15, 2019 5:31 am

Re: Has anyone managed to launch a selenium cef, using pytho

Postby tzahisofer » Sun Nov 17, 2019 5:10 pm

Hold on - I got the binary location setting wrong.
It should be:
chrome_options.binary_location ="C:\work\cefsimple.exe"

Stay tuned for an update
tzahisofer
Newbie
 
Posts: 8
Joined: Fri Nov 15, 2019 5:31 am

Re: Has anyone managed to launch a selenium cef, using pytho

Postby tzahisofer » Sun Nov 17, 2019 5:33 pm

Issue solved!
Mainly a stupid mistake I have made in setting the binary_location, but in addition, the below is needed:

def initializeDriver():
chrome_options = webdriver.ChromeOptions()
chrome_options.binary_location = r"C:\work\cef-project\build\third_party\cef\cef_binary_77.1.18+g8e8d602+chromium-77.0.3865.120_windows64\tests\cefsimple\Debug\cefsimple.exe"
chrome_options.add_argument('--remote-debugging-port=12345')
chrome_driver_binary = r"C:\work\chromedriver_for_cef\chromedriver.exe"
driver = webdriver.Chrome(chrome_driver_binary, chrome_options=chrome_options)
driver.implicitly_wait(0.5)
return driver

Needed both the cef Chrome locatio nand the right chromedriver version that support it.

Hope it helps someone.

Tnx!
tzahisofer
Newbie
 
Posts: 8
Joined: Fri Nov 15, 2019 5:31 am


Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 4 guests