diff --git a/docs/desktop.md b/docs/desktop.md index 9809c89..3fd849a 100644 --- a/docs/desktop.md +++ b/docs/desktop.md @@ -5,13 +5,28 @@ For now to drive the Chromium-based Opera you’ll need to use the `RemoteWebDri ## Creating an OperaDriver service ```python -# Create OperaDriver service: +# Create and start OperaDriver service: from selenium.webdriver.chrome import service webdriver_service = service.Service(opera_driver_exe_path, port_on_which_service_will_be_running) +webdriver_service.start() ``` +### Creating a remote webdriver for selenium 4 -### Creating a remote webdriver +```python +# Create OperaDriver options: +from selenium import webdriver +options = webdriver.ChromeOptions() +options.binary_location = opera_exe_path +options.add_experimental_option('w3c', True) +``` + +```python +# Create remote webdriver +remote = webdriver.Remote(webdriver_service.service_url, options=options) +``` + +### Creating a remote webdriver for selenium 2, 3 ```python # Create remote webdriver: diff --git a/docs/python-setup-step-by-step.md b/docs/python-setup-step-by-step.md index df72216..28f565d 100644 --- a/docs/python-setup-step-by-step.md +++ b/docs/python-setup-step-by-step.md @@ -36,7 +36,10 @@ ## Run example For Android use [pure Selenium](../examples/android.py) or [Appium](../examples/appium_simple.py). -Desktop example: [desktop.py](../examples/desktop.py). + +Desktop example for selenium 2 and selenium 3: [desktop_selenium_2.x_and_3.x.py](../examples/desktop_selenium_2.x_and_3.x.py). + +Desktop example for selenium 4: [desktop_selenium_4.x.py](../examples/desktop_selenium_4.x.py). ## Troubleshooting diff --git a/examples/desktop.py b/examples/desktop_selenium_2.x_and_3.x.py similarity index 100% rename from examples/desktop.py rename to examples/desktop_selenium_2.x_and_3.x.py diff --git a/examples/desktop_selenium_4.x.py b/examples/desktop_selenium_4.x.py new file mode 100644 index 0000000..408147d --- /dev/null +++ b/examples/desktop_selenium_4.x.py @@ -0,0 +1,22 @@ +import time + +from selenium import webdriver +from selenium.webdriver.chrome import service + +from selenium.webdriver.common.by import By + +webdriver_service = service.Service("path/to/operadriver") +webdriver_service.start() + +options = webdriver.ChromeOptions() +options.binary_location = "path/to/operabrowser" +options.add_experimental_option('w3c', True) + +driver = webdriver.Remote(webdriver_service.service_url, options=options) + +driver.get('https://www.google.com/') +input_txt = driver.find_element(By.NAME, 'q') +input_txt.send_keys('operadriver\n') + +time.sleep(5) # see the result +driver.quit()