Page 1 of 1
Has anyone managed to launch a selenium cef, using python?
Posted:
Sun Nov 17, 2019 8:34 am
by tzahisofer
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
Re: Has anyone managed to launch a selenium cef, using pytho
Posted:
Sun Nov 17, 2019 3:14 pm
by magreenblatt
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.
Re: Has anyone managed to launch a selenium cef, using pytho
Posted:
Sun Nov 17, 2019 3:57 pm
by tzahisofer
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.
Re: Has anyone managed to launch a selenium cef, using pytho
Posted:
Sun Nov 17, 2019 4:05 pm
by magreenblatt
Does it work with Google Chrome? What does that code look like?
Re: Has anyone managed to launch a selenium cef, using pytho
Posted:
Sun Nov 17, 2019 4:58 pm
by tzahisofer
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.
Re: Has anyone managed to launch a selenium cef, using pytho
Posted:
Sun Nov 17, 2019 5:10 pm
by tzahisofer
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
Re: Has anyone managed to launch a selenium cef, using pytho
Posted:
Sun Nov 17, 2019 5:33 pm
by tzahisofer
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!