Developer Interface¶
This part of the documentation describes the interfaces for using pomcorn.
WebView¶
WebView
¶
Class for storing basic shortcuts for interacting with the browser.
Source code in pomcorn/web_view.py
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 | |
current_url
property
¶
Return the current webdriver URL.
__init__(webdriver, *, app_root, wait_timeout, poll_frequency=0)
¶
Initialize webview.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
webdriver
|
WebDriver
|
Instance of a class for managing the browser. |
required |
app_root
|
str
|
The URL of browser. |
required |
wait_timeout
|
float
|
Number of seconds before timing out. |
required |
poll_frequency
|
float
|
Time between checks of |
0
|
Source code in pomcorn/web_view.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
drag_and_drop(source, target)
¶
Perform drag and drop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
WebElement
|
The web element instance to drag. |
required |
target
|
WebElement
|
The web element instance to drag into. |
required |
Source code in pomcorn/web_view.py
399 400 401 402 403 404 405 406 407 | |
execute_javascript(script, *args)
¶
Execute simple javascript.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
script
|
str
|
JavaScript code as a string object. |
required |
*args
|
Any applicable arguments for your JavaScript. |
()
|
Source code in pomcorn/web_view.py
447 448 449 450 451 452 453 454 455 | |
get_input_value(label)
¶
Find input element by label and get it's value.
Source code in pomcorn/web_view.py
441 442 443 444 445 | |
get_wait(timeout=None)
¶
Get WebDriverWait instance.
If no arguments are provided, returns the default wait instance.
Source code in pomcorn/web_view.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
iframe_switcher_manager(locator)
¶
Context manager for interacting with iframes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locator
|
Locator
|
Instance of a class to locate the element in the browser. |
required |
Source code in pomcorn/web_view.py
470 471 472 473 474 475 476 477 478 479 480 | |
init_element(locator)
¶
Shortcut for initializing Element instances.
Note: To be consistent with the method of the same name in
Component, try to use keyword when specifying the locator
argument whenever possible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locator
|
TInitLocator
|
Instance of a class to locate the element in the browser. |
required |
Source code in pomcorn/web_view.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
init_elements(locator)
¶
Shortcut for initializing many Element instances via single locator.
Note: Only supports Xpath locators.
Note: To be consistent with the method of the same name in
Component, try to use keyword when specifying the locator
argument whenever possible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locator
|
XPathLocator
|
Instance of a class to locate the element in the browser. |
required |
Source code in pomcorn/web_view.py
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 | |
iter_locators(locator, only_visible=False)
¶
Get the list of the locators where each of them match an element.
For example, there are multiple elements on the page that matches
XPathLocator("//a").
This method return the set of locators like:
* XPathLocator("(//a)[1]")
* XPathLocator("(//a)[2]")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locator
|
XPathLocator
|
Instance of a class to locate the element in the browser. |
required |
only_visible
|
bool
|
Flag for viewing visible elements. If this is |
False
|
Source code in pomcorn/web_view.py
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 | |
scroll_to(target)
¶
Scroll page to target.
Scroll to the center of target vertically and to the center of target horizontally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
WebElement
|
The web element instance to scroll to. |
required |
Source code in pomcorn/web_view.py
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
scroll_to_bottom()
¶
Scroll browser to bottom.
Source code in pomcorn/web_view.py
435 436 437 438 439 | |
scroll_to_top()
¶
Scroll browser to top.
Source code in pomcorn/web_view.py
429 430 431 432 433 | |
switch_to_default()
¶
Switch webdriver's focus to default content.
Source code in pomcorn/web_view.py
457 458 459 | |
switch_to_iframe(locator)
¶
Switch webdriver's focus to iframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locator
|
Locator
|
Instance of a class to locate the element in the browser. |
required |
Source code in pomcorn/web_view.py
461 462 463 464 465 466 467 468 | |
wait_until_clickable(locator, timeout=None)
¶
Wait until element matching locator becomes clickable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locator
|
Locator
|
Instance of a class to locate the element in the browser. |
required |
timeout
|
float | None
|
Number of seconds to wait until timing out. By default,
method waits for |
None
|
Raises:
| Type | Description |
|---|---|
TimeoutException
|
If after |
Source code in pomcorn/web_view.py
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 | |
wait_until_locator_invisible(locator, timeout=None)
¶
Wait until element matching locator becomes invisible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locator
|
Locator
|
Instance of a class to locate the element in the browser. |
required |
timeout
|
float | None
|
Number of seconds to wait until timing out. By default,
method waits for |
None
|
Raises:
| Type | Description |
|---|---|
TimeoutException
|
If after |
Source code in pomcorn/web_view.py
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 | |
wait_until_locator_visible(locator, timeout=None)
¶
Wait until element matching locator becomes visible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locator
|
Locator
|
Instance of a class to locate the element in the browser. |
required |
timeout
|
float | None
|
Number of seconds to wait until timing out. By default,
method waits for |
None
|
Raises:
| Type | Description |
|---|---|
TimeoutException
|
If after |
Source code in pomcorn/web_view.py
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 | |
wait_until_not_exists_in_dom(element, timeout=None)
¶
Wait until element ceases to exist in DOM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
element
|
PomcornElement[TLocator_co] | TLocator_co
|
Instance of a class to locate the element in the browser or instance of element. |
required |
timeout
|
float | None
|
Number of seconds to wait until timing out. By default,
method waits for |
None
|
Raises:
| Type | Description |
|---|---|
TimeoutException
|
If after |
Source code in pomcorn/web_view.py
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 | |
wait_until_text_is_in_element(text, locator, timeout=None)
¶
Wait until text is present in the specified element by locator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
locator
|
Locator
|
Instance of a class to locate the element in the browser. |
required |
text
|
str
|
Text that should be presented in element. |
required |
timeout
|
float | None
|
Number of seconds to wait until timing out. By default,
method waits for |
None
|
Raises:
| Type | Description |
|---|---|
TimeoutException
|
If after |
Source code in pomcorn/web_view.py
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 | |
wait_until_url_changes(url=None, timeout=None)
¶
Wait until url changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str | None
|
Browser URL which should be changed. If the argument is not
input, will be used |
None
|
timeout
|
float | None
|
Number of seconds to wait until timing out. By default,
method waits for |
None
|
Raises:
| Type | Description |
|---|---|
TimeoutException
|
If after |
Source code in pomcorn/web_view.py
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 | |
wait_until_url_contains(url, timeout=None)
¶
Wait until browser's url contains input url.
By default, method waits for self.wait_timeout seconds.
If you need to change timeout, you can specify it in timeout
argument.
Raises:
| Type | Description |
|---|---|
TimeoutException
|
If after |
Source code in pomcorn/web_view.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
wait_until_url_not_contains(url, timeout=None)
¶
Wait until browser's url doesn't not contains input url.
By default, method waits for self.wait_timeout seconds.
If you need to change timeout, you can specify it in timeout
argument.
Raises:
| Type | Description |
|---|---|
TimeoutException
|
If after |
Source code in pomcorn/web_view.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
Page¶
Page
¶
Bases: WebView
The class for representing a web page.
It contains the element and components of the page and utils methods for page manipulation.
Source code in pomcorn/page.py
8 9 10 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 | |
__init__(webdriver, *, app_root=None, wait_timeout=5.0, poll_frequency=0.01)
¶
Initialize page.
Call wait_until_loaded method after initialization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
webdriver
|
WebDriver
|
Instance of a class for managing the browser. |
required |
app_root
|
str | None
|
The URL of base page, by default the value of |
None
|
wait_timeout
|
float
|
Number of seconds before timing out. |
5.0
|
poll_frequency
|
float
|
Time between checks of |
0.01
|
Source code in pomcorn/page.py
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 | |
check_page_is_loaded()
¶
Return result of check that the page is loaded.
Some pages can be slow to load and cause problems checking for unloaded items. To be sure the page is loaded, this property should return the result of checking for the slowest parts of the page.
Source code in pomcorn/page.py
48 49 50 51 52 53 54 55 56 | |
click_on_page()
¶
Click on (1, 1) coordinates of page (left upper corner).
Allows you to move focus away from an element, for example, if it is currently unavailable for interaction.
Source code in pomcorn/page.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
navigate(url)
¶
Navigate absolute URL.
Replace the browser URL with the entered one.
Source code in pomcorn/page.py
137 138 139 140 141 142 143 | |
navigate_relative(relative_url='/')
¶
Navigate to URL relative to application root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
relative_url
|
str
|
Relative URL |
'/'
|
Source code in pomcorn/page.py
145 146 147 148 149 150 151 152 153 154 | |
open(webdriver, *, app_root=None)
classmethod
¶
Open page and initialize page object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
webdriver
|
WebDriver
|
Instance of a WebDriver class for managing the browser. |
required |
app_root
|
str | None
|
The URL of page, by default the value of |
None
|
Source code in pomcorn/page.py
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 | |
open_from_url(webdriver, *, path, app_root=None, **kwargs)
classmethod
¶
Open page from relative path and initialize page object.
Add path to app_root in browser URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
webdriver
|
WebDriver
|
Instance of a WebDriver class for managing the browser. |
required |
app_root
|
str | None
|
The URL of page, by default the value of |
None
|
path
|
str
|
Relative URL. |
required |
**kwargs
|
Additional arguments passed to the page object initialization. |
{}
|
Source code in pomcorn/page.py
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 | |
refresh()
¶
Refresh web page and wait until it is loaded.
Source code in pomcorn/page.py
120 121 122 123 | |
wait_until_loaded(timeout=None)
¶
Wait until page is loaded.
Source code in pomcorn/page.py
125 126 127 128 129 130 131 132 133 134 135 | |
Components¶
Component
¶
Bases: WebView, Generic[TPage]
The class to represent a page component that depends on base locator.
It contains page elements, components and utils methods for page manipulation, but as a separate entity that can be reused for different pages with common elements.
Implement wait methods until the component becomes visible or invisible.
Source code in pomcorn/component.py
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 | |
__init__(page, base_locator=None, wait_until_visible=True)
¶
Initialize component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page
|
TPage
|
An instance of the page that uses this component. |
required |
base_locator
|
XPathLocator | None
|
Instance of a class to locate the component in the browser. Used in relative element initialization methods and visibility waits. You also can specify it as attribute. |
None
|
wait_until_visible
|
bool
|
Whether to wait for the component to become visible before completing initialization or not. |
True
|
Source code in pomcorn/component.py
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 | |
init_element(*, relative_locator=None, locator=None)
¶
init_element(*, locator: locators.XPathLocator) -> XPathElement
init_element(*, relative_locator: locators.XPathLocator) -> XPathElement
Initialize element including base locator.
Use relative_locator if you need to include base_locator, otherwise
use locator.
Raises:
| Type | Description |
|---|---|
ValueError
|
If both arguments were passed or neither. |
Source code in pomcorn/component.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
init_elements(*, relative_locator=None, locator=None)
¶
init_elements(*, locator: locators.XPathLocator | None = None) -> list[XPathElement]
init_elements(*, relative_locator: locators.XPathLocator | None = None) -> list[XPathElement]
Initialize list of elements including base locator.
Use relative_locator if you need to include base_locator, otherwise
use locator.
Raises:
| Type | Description |
|---|---|
ValueError
|
If both arguments were passed or neither. |
Source code in pomcorn/component.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
wait_until_invisible(timeout=None, **kwargs)
¶
Wait until component becomes invisible.
By default, method waits for self.wait._timeout seconds.
If you need to change timeout, you can specify it in timeout
argument.
Source code in pomcorn/component.py
187 188 189 190 191 192 193 194 195 | |
wait_until_visible(timeout=None, **kwargs)
¶
Wait until component becomes visible.
By default, method waits for self.wait._timeout seconds.
If you need to change timeout, you can specify it in timeout
argument.
Source code in pomcorn/component.py
177 178 179 180 181 182 183 184 185 | |
ListComponent
¶
Bases: Component[TPage], Generic[ListItemType, TPage]
Class to represent a list-like component.
It contains standard properties and methods for working with list-like components:
- count
- all
- get_item_by_text()
Waits for base_item_locator property to be overridden or one of the
attributes (item_locator or relative_item_locator) to be specified.
Source code in pomcorn/component.py
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 | |
all
property
¶
Get all items of list.
base_item_locator
property
¶
Get the base locator of list item.
Raises:
| Type | Description |
|---|---|
ValueError
|
If both attributes are specified. |
NotImplementedError
|
If no attribute has been specified, |
count
property
¶
Get count of list items.
__class_getitem__(item)
¶
Create parameterized versions of generic classes.
This method is called when the class is used as a parameterized type, such as MyGeneric[int] or MyGeneric[List[str]].
We override this method to store values passed in generic parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls
|
The generic class itself. |
required | |
item
|
tuple[type, ...]
|
The type used for parameterization. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
type |
Any
|
A parameterized version of the class with the specified type. |
Source code in pomcorn/component.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
__init_subclass__()
¶
Run logic for getting/overriding item_class attr for subclasses.
Source code in pomcorn/component.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
get_item_by_text(text, exact=False)
¶
Get list item by text.
Source code in pomcorn/component.py
362 363 364 365 366 367 368 | |
get_list_item_class()
classmethod
¶
Return class passed in Generic[ListItemType].
Source code in pomcorn/component.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |
is_valid_item_class(item_class)
classmethod
¶
Check that specified item_class is valid.
Valid item_class should be
* a class and subclass of Component
* or TypeAlias based on Component
Source code in pomcorn/component.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | |
PomcornElement¶
Note
This class is returned when the Element descriptor or the
init_element/init_elements methods of the page or components are used.
PomcornElement
¶
Bases: Generic[TLocator_co]
The class to represent a simple element (tag) on the page.
Contains methods for the interaction with an element on the browser page.
Source code in pomcorn/element.py
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 | |
exists_in_dom
property
¶
Check if element is present in html, can be not visible.
is_displayed
property
¶
Check if element is displayed.
If element is not present in the html, return False.
is_enabled
property
¶
Check if element is enabled.
It is primarily used with buttons.
is_selected
property
¶
Check if element is selected.
It is predominantly used with radio buttons, dropdowns and checkboxes.
__init__(web_view, locator)
¶
Init page element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
web_view
|
WebView
|
Instance of a webview. |
required |
locator
|
TLocator_co
|
Instance of a class to locate the element in the browser. |
required |
Source code in pomcorn/element.py
25 26 27 28 29 30 31 32 33 34 | |
add_debug_mark()
¶
Set element background to red.
Should be used only for debugging.
Source code in pomcorn/element.py
413 414 415 416 417 418 419 420 | |
clear(only_visible=True)
¶
Clear element (input) and it's value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
only_visible
|
bool
|
Flag for viewing visible elements. If this is |
True
|
Source code in pomcorn/element.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
click(only_visible=True, wait_until_clickable=True, center_element=False)
¶
Click on element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
only_visible
|
bool
|
Flag for viewing visible elements. If this is |
True
|
wait_until_clickable
|
bool
|
Wait until the element is clickable before
clicking, or not (default |
True
|
center_element
|
bool
|
Scroll the page until the element is in
the center, or not scroll (default |
False
|
By default, webdriver scrolls to the element before clicking if the element is not in viewport or is behind overlays (header/footer tags). If the element is in viewport but overlapped, set center_element to True to scroll until element is in the center of the screen.
Source code in pomcorn/element.py
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 | |
drag_and_drop(target, only_visible=True)
¶
Drag and drop page object on target object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
PomcornElement[TLocator_co]
|
The element instance to drag into. |
required |
only_visible
|
bool
|
Flag for viewing visible elements. If this is |
True
|
Source code in pomcorn/element.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | |
fill(text, only_visible=True, clear=True)
¶
Fill element with text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The text that will be sent to the element to be filled. |
required |
only_visible
|
bool
|
Flag for viewing visible elements. If this is |
True
|
clear
|
bool
|
Whether the element needs to be cleared before filling it
or not (default |
True
|
Source code in pomcorn/element.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
get_attribute(attribute_name, only_visible=True)
¶
Get value of attribute from element.
If attribute is not found, return empty string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute_name
|
str
|
Element attribute name.. |
required |
only_visible
|
bool
|
Flag for viewing visible elements. If this is |
True
|
Source code in pomcorn/element.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
get_element(only_visible=True)
¶
Get selenium instance(WebElement) of element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
only_visible
|
bool
|
Flag for viewing visible elements. If this is |
True
|
Source code in pomcorn/element.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
get_text(only_visible=True)
¶
Get text from element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
only_visible
|
bool
|
Flag for viewing visible elements. If this is |
True
|
Source code in pomcorn/element.py
241 242 243 244 245 246 247 248 249 250 251 | |
get_value(only_visible=True)
¶
Get value of value attribute from element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
only_visible
|
bool
|
Flag for viewing visible elements. If this is |
True
|
Source code in pomcorn/element.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 | |
get_value_of_css_property(property_name, only_visible=True)
¶
Return value of a CSS property.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
property_name
|
str
|
Name of CSS property. |
required |
only_visible
|
bool
|
Flag for viewing visible elements. If this is |
True
|
Source code in pomcorn/element.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |
hover_to(only_visible=True)
¶
Hover cursor to element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
only_visible
|
bool
|
Flag for viewing visible elements. If this is |
True
|
Source code in pomcorn/element.py
383 384 385 386 387 388 389 390 391 392 393 394 | |
remove_debug_mark()
¶
Remove debug mark.
Source code in pomcorn/element.py
422 423 424 425 426 427 428 | |
scroll_to(only_visible=True)
¶
Scroll page until element is visible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
only_visible
|
bool
|
Flag for viewing visible elements. If this is |
True
|
Source code in pomcorn/element.py
373 374 375 376 377 378 379 380 381 | |
select(value, only_visible=True)
¶
Perform select on element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Value for selecting an element based on visible text. |
required |
only_visible
|
bool
|
Flag for viewing visible elements. If this is |
True
|
Source code in pomcorn/element.py
316 317 318 319 320 321 322 323 324 325 | |
send_keys(keys, only_visible=True)
¶
Send keys to element.
Simulate user keystrokes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
str
|
The names of the keys in the form of a single string. More keys: https://www.selenium.dev/selenium/docs/api/py/webdriver/selenium.webdriver.common.keys.html |
required |
only_visible
|
bool
|
Flag for viewing visible elements. If this is |
True
|
Source code in pomcorn/element.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
set_attribute(attribute_name, value, only_visible=True)
¶
Set value to element attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute_name
|
str
|
Element attribute name. |
required |
value
|
str
|
New value for attribute. |
required |
only_visible
|
bool
|
Flag for viewing visible elements. If this is |
True
|
Source code in pomcorn/element.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
wait_until_clickable(timeout=None)
¶
Wait until element becomes clickable.
By default, method waits for self.web_view.wait_timeout seconds.
If you need to change timeout, you can specify it in timeout
argument.
Raises:
| Type | Description |
|---|---|
TimeoutException
|
If after |
Source code in pomcorn/element.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
wait_until_invisible(timeout=None)
¶
Wait until element becomes invisible.
By default, method waits for self.web_view.wait_timeout seconds.
If you need to change timeout, you can specify it in timeout
argument.
Raises:
| Type | Description |
|---|---|
TimeoutException
|
If after |
Source code in pomcorn/element.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
wait_until_not_exists_in_dom(timeout=None)
¶
Wait until element ceases to exist in DOM.
By default, method waits for self.web_view.wait_timeout seconds.
If you need to change timeout, you can specify it in timeout
argument.
Raises:
| Type | Description |
|---|---|
TimeoutException
|
If after |
Source code in pomcorn/element.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
wait_until_text_is_in_element(text, timeout=None)
¶
Wait until text is present in element.
By default, method waits for self.web_view.wait_timeout seconds.
If you need to change timeout, you can specify it in timeout
argument.
Raises:
| Type | Description |
|---|---|
TimeoutException
|
If after |
Source code in pomcorn/element.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
wait_until_visible(timeout=None)
¶
Wait until element becomes visible.
By default, method waits for self.web_view.wait_timeout seconds.
If you need to change timeout, you can specify it in timeout
argument.
Raises:
| Type | Description |
|---|---|
TimeoutException
|
If after |
Source code in pomcorn/element.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |