chrome_driver
This module provides the ChromeDriver class for handling ChromeDriver related operations.
The ChromeDriver class provides methods for setting up Chrome options and creating a WebDriver instance.
ChromeDriver
A class used to handle ChromeDriver related operations.
Attributes
chrome_options : list a list of Chrome options to be set chrome_preferences : dict a dictionary of Chrome preferences to be set chrome_version : str the version of Chrome to be used proxies : str the proxies to be used grid_execution : bool a flag indicating whether grid execution is enabled chrome_options : ChromeOptions the ChromeOptions object
Methods
setup_options(): Sets up Chrome options. create_driver(selenium_grid_ip=None): Creates a WebDriver instance.
Source code in libs\cafex_ui\src\cafex_ui\web_client\drivers\chrome_driver.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
__init__(chrome_options=None, chrome_preferences=None, proxies=None, grid_execution=False, chrome_version=None, run_on_browserstack=False, browserstack_username=None, browserstack_access_key=None, browserstack_capabilities=None)
Constructs all the necessary attributes for the ChromeDriver object.
Parameters
chrome_options : list, optional a list of Chrome options to be set (default is None) chrome_preferences: dict, optional a dictionary of Chrome preferences to be set (default is None) proxies : str, optional the proxies to be used (default is None) grid_execution : bool, optional a flag indicating whether grid execution is enabled (default is False) chrome_version : str, optional the version of Chrome to be used (default is None) run_on_browserstack : bool, optional a flag indicating whether to run on BrowserStack (default is False) browserstack_username : str, optional the username for BrowserStack (default is None) browserstack_access_key : str, optional the access key for BrowserStack (default is None) browserstack_capabilities: dict, optional the BrowserStack capabilities (default is None)
Examples
chrome_driver = ChromeDriver(chrome_options=['--headless'], project_path='/path/to/project') chrome_driver.chrome_options ['--headless']
Source code in libs\cafex_ui\src\cafex_ui\web_client\drivers\chrome_driver.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
create_driver(selenium_grid_ip=None)
Creates a WebDriver instance.
The method creates a WebDriver instance based on the attributes of the ChromeDriver object and the provided parameters.
Parameters
selenium_grid_ip : str, optional the IP of the Selenium grid (default is None) Returns
web_driver : WebDriver the created WebDriver instance
Examples
chrome_driver = ChromeDriver(chrome_options=['--headless']) driver = chrome_driver.create_driver() driver.name 'chrome'
Source code in libs\cafex_ui\src\cafex_ui\web_client\drivers\chrome_driver.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
get_window_size_from_options()
Parses the window size from the list_chrome_options attribute.
Returns
tuple A tuple containing the width and height as integers, or None if not specified.
Examples
chrome_driver = ChromeDriver(chrome_options=['--window-size=800x600']) chrome_driver.get_window_size_from_options() (800, 600)
Source code in libs\cafex_ui\src\cafex_ui\web_client\drivers\chrome_driver.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
setup_options()
Sets up Chrome options.
The method sets up Chrome options based on the attributes of the ChromeDriver object.
Examples
chrome_driver = ChromeDriver(chrome_options=['--headless']) chrome_driver.setup_options() '--headless' in chrome_driver.chrome_options_object.arguments True
Source code in libs\cafex_ui\src\cafex_ui\web_client\drivers\chrome_driver.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|