webdriver_interactions
WebDriverInteractions
This class contains methods to perform various operations on a browser and its elements.
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
11 12 13 14 15 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 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
|
__init__(web_driver=None, default_explicit_wait=None, default_implicit_wait=None)
Initializes WebClientActions with a driver and optional explicit wait.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
web_driver
|
WebDriver
|
The selenium webdriver instance. if not provided, it will be picked from Session Store |
None
|
default_explicit_wait
|
int
|
The default explicit wait time (in seconds). If not provided, it will be retrieved from ConfigUtils. |
None
|
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
accept_alert(explicit_wait=None)
Accept the alert if present.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().accept_alert() CafeXWeb().accept_alert(30)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
explicit_wait
|
int
|
An integer representing the explicit wait time (in seconds) for the alert to be present. |
None
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
|
add_cookie(cookie)
Add a cookie to the current session.
Examples:
from cafex_ui import CafeXWeb cookie = {"name": "cookie_name", "value": "cookie_value"} CafeXWeb().add_cookie(cookie)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cookie
|
dict
|
A dictionary containing the cookie name and value. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 |
|
check_cookies(cookies_to_search, complete_cookie_data)
Search the list of cookies in the current set of cookies.
Examples:
from cafex_ui import CafeXWeb cookies_to_search = ["cookie1", "cookie2"] complete_cookie_data = {"cookie1": "value1", "cookie3": "value3"} CafeXWeb().check_cookies(cookies_to_search, complete_cookie_data)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cookies_to_search
|
list
|
List of cookies to be searched. |
required |
complete_cookie_data
|
dict
|
Dictionary of cookies generated for the current page. |
required |
Returns:
Type | Description |
---|---|
bool
|
A boolean indicating whether any of the cookies to search are present in the complete cookie data. |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 |
|
delete_cookies(cookie_name=None, all_cookies=False)
Delete the cookie from the current session.If all_cookies is True, it will delete all cookies.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().delete_cookies("cookie_name")
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cookie_name
|
str
|
Name of the cookie to be deleted. |
None
|
all_cookies
|
bool
|
A boolean value to delete all cookies |
False
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
|
dismiss_alert(explicit_wait=None)
Dismiss the alert if present.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().dismiss_alert() CafeXWeb().dismiss_alert(30)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
explicit_wait
|
int
|
An integer representing the explicit wait time (in seconds) for the alert to be present. |
None
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 |
|
get_alert_text(explicit_wait=None)
Return the text of the alert if present.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().get_alert_text() CafeXWeb().get_alert_text(30)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
explicit_wait
|
int
|
An integer representing the explicit wait time (in seconds) for the alert to be present. |
None
|
Returns:
Type | Description |
---|---|
A string representing the text of the alert. |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
|
get_all_window_handles()
Get all current window handles which are present.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().get_all_window_handles()
Returns:
Type | Description |
---|---|
A list of window handles. |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
|
get_cookie_value(cookie_name)
Return the value of the cookie if present, otherwise return "No Cookie Present".
Examples:
from cafex_ui import CafeXWeb CafeXWeb().get_cookie_value("session_id")
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cookie_name
|
str
|
Name of the cookie to be retrieved. |
required |
Returns:
Type | Description |
---|---|
str
|
A string representing the value of the cookie. |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
|
get_current_url(expected_url=None, explicit_wait=None)
Return the current URL of the browser after waiting for the page to stop loading.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().get_current_url() CafeXWeb().get_current_url("http://example.com",30)
Args: expected_url: A string representing the URL of the page which user is expecting. explicit_wait: An integer representing the maximum time to wait for the page to stop loading (in seconds).
Returns:
Type | Description |
---|---|
str
|
A string representing the current URL of the browser. |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
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 |
|
get_current_window_handle()
Get the current window handle.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().get_current_window_handle()
Returns:
Type | Description |
---|---|
A string representing the current window handle. |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|
get_title(expected_title=None, explicit_wait=None)
Return the title of the browser after waiting for it to be present.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().get_title() CafeXWeb().get_title("Example Title",30)
Args: expected_title: A string representing the title of the page which user is expecting. explicit_wait: An integer representing the maximum time to wait for the title to be present (in seconds).
Returns:
Type | Description |
---|---|
str
|
A string representing the title of the browser. |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
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 |
|
go_to_url(endpoint, base_url=None, explicit_wait=None)
Combine the base URL and the partial URL/page URL and navigate to the resultant URL.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().go_to_url("/endpoint", base_url="http://example.com") CafeXWeb().web_client_actions.go_to_url("/endpoint")
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint
|
str
|
A string representing the partial URL which will be combined with the base URL/the platform. |
required |
base_url
|
str
|
A string representing the URL of the platform. |
None
|
explicit_wait
|
int
|
An integer representing the explicit wait time for the page to load. |
None
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
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 |
|
navigate(url, explicit_wait=None)
Navigate to the given URL and wait until the page is fully loaded.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().navigate("http://example.com")
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
A string representing the URL to which the driver needs to be navigated to. |
required |
explicit_wait
|
int
|
An integer representing the explicit wait time (in seconds) for the page to load. |
None
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
navigate_back(explicit_wait=None)
Navigate back in the browser history.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().navigate_back() CafeXWeb().navigate_back(30)
Args: explicit_wait: An integer representing the time to wait for the page to load.
Returns:
Type | Description |
---|---|
None
|
None |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
navigate_forward(explicit_wait=None)
Navigate forward in the browser history.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().navigate_forward() CafeXWeb().navigate_forward(30)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
explicit_wait
|
int
|
An integer representing the time to wait for the page to load. |
None
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
return_cookie_list()
Return the cookie list created.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().return_cookie_list()
Returns:
Type | Description |
---|---|
dict
|
A dictionary containing the cookies. |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
|
send_keys_to_alert(text=None, explicit_wait=None)
Enter the given text in the alert box if present.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().send_keys_to_alert("Sample text") CafeXWeb().send_keys_to_alert("Sample text", 30)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
A string representing the text to be entered in the alert box. |
None
|
explicit_wait
|
int
|
An integer representing the explicit wait time (in seconds) for the alert to be present. |
None
|
Returns:
Type | Description |
---|---|
None |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 |
|
switch_to_default_content()
Switch back to the default frame.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().switch_to_default_content()
Returns:
Type | Description |
---|---|
None |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
|
switch_to_frame(frame_reference, explicit_wait=None)
Switch to frame based on reference.
Examples:
from cafex_ui import CafeXWeb web_element = CafeXWeb().get_web_element(locator="xpath=//iframe[@name='frame_name']") CafeXWeb().switch_to_frame('frame_name') CafeXWeb().switch_to_frame(1) CafeXWeb().switch_to_frame(web_element)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frame_reference
|
A string representing the locator of the frame to switch into. |
required | |
explicit_wait
|
int
|
An integer representing the explicit wait time (in seconds) for the frame to be available. |
None
|
Returns:
Type | Description |
---|---|
None |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
|
switch_to_last_open_window()
Switch the user to the last open window.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().switch_to_last_open_window()
Returns:
Type | Description |
---|---|
None |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
|
switch_to_window(**kwargs)
Switch to window by window handle or window title.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().switch_to_window(window_handle='value of window handle') CafeXWeb().switch_to_window(title='the page title')
Parameters:
Name | Type | Description | Default |
---|---|---|---|
window_handle
|
A string representing the handle ID of the window user wants to switch to. |
required | |
title
|
A string representing the title of the window user wants to switch to. |
required | |
new_window
|
A boolean value to switch to the new window. |
required | |
new_tab
|
A boolean value to switch to the new tab. |
required |
Returns:
Type | Description |
---|---|
None |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
|
wait_for_page_readyState(explicit_wait=None)
Wait until the page's readyState is 'complete' or the specified wait time elapses.
Examples:
from cafex_ui import CafeXWeb CafeXWeb().wait_for_page_readyState(30)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
explicit_wait
|
int
|
An integer representing the maximum wait time in seconds. |
None
|
Returns:
Type | Description |
---|---|
None |
Source code in libs\cafex_ui\src\cafex_ui\web_client\web_client_actions\webdriver_interactions.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|