I am trying to control cefpython (cefpython3==57.0) chromium embedded framework with selenium (chromedriver.exe==2.9)
I have came so far from beginning, i searched every corner of the web to find none on this topic. It would be great if anyone have knowledge on this share their knowledge here. Not only me, everyone searching this question will find this useful.
Luckily found this simple tutorial https://github.com/sokolnikovalexey/cef-pyhton-selenium
In step 2 author telling to set APPLICATION_PATH to path of cef application(cefclient.exe)
Unfortunately i doun't have that file in my folder. All i can find is subprocess.exe "C:\Users\vaas\AppData\Local\Programs\Python\Python36\Lib\site-packages\cefpython3\subprocess.exe"
But this doesn't start the cef, i am getting webdriver error when using chromedriver.exe (2.9):
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
when using chromedriver.exe (<2.9):
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
here is offcial cef tut which show how to use chromedriver with cef, but this tutorial only applicable to java. https://bitbucket.org/chromiumembedded/cef/wiki/UsingChromeDriver.md
here is the sample code i use from the first tutorial.
import time
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
class PythonOrgSearch(unittest.TestCase):
# APPLICATION_PATH = '/path/to/your/cef/app.exe'
APPLICATION_PATH = r'C:\Users\vaas\AppData\Local\Programs\Python\Python36\Lib\site-packages\cefpython3\subprocess.exe'
TEST_PAGE_PATH = 'http://www.google.com' #here should be path to your testing page
def setUp(self):
options = webdriver.ChromeOptions()
options.binary_location = self.APPLICATION_PATH
self.driver = webdriver.Chrome(chrome_options=options)
self.driver.get(self.TEST_PAGE_PATH)
def test_math_operations(self):
driver = self.driver
operand1 = driver.find_element_by_id('operand1')
operand2 = driver.find_element_by_id('operand2')
result = driver.find_element_by_id('result')
calculateButton = driver.find_element_by_id('calculateButton')
operand1.send_keys('2')
operand2.send_keys('3')
calculateButton.click()
assert result.get_attribute('value') == '5'
def tearDown(self):
self.driver.close()
if __name__ == "__main__":
unittest.main()
I have contacted the author of the tutorial as well. Will update the progress here.
Thanks.