code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
async def bounds(self) -> Quad: """ Element's bounding box coordinates. Returns coordinates in CSS pixels relative to document origin. """ command = DomCommands.get_box_model(object_id=self._object_id) response: GetBoxModelResponse = await self._execute_command(command) ...
Element's bounding box coordinates. Returns coordinates in CSS pixels relative to document origin.
bounds
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
async def inner_html(self) -> str: """Element's HTML content (actually returns outerHTML).""" command = DomCommands.get_outer_html(object_id=self._object_id) response: GetOuterHTMLResponse = await self._execute_command(command) return response['result']['outerHTML']
Element's HTML content (actually returns outerHTML).
inner_html
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
async def get_bounds_using_js(self) -> dict[str, int]: """ Get element bounds using JavaScript getBoundingClientRect(). Returns coordinates relative to viewport (alternative to bounds property). """ response = await self._execute_script(Scripts.BOUNDS, return_by_value=True) ...
Get element bounds using JavaScript getBoundingClientRect(). Returns coordinates relative to viewport (alternative to bounds property).
get_bounds_using_js
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
async def take_screenshot(self, path: str, quality: int = 100): """ Capture screenshot of this element only. Automatically scrolls element into view before capturing. """ bounds = await self.get_bounds_using_js() clip = Viewport( x=bounds['x'], y=...
Capture screenshot of this element only. Automatically scrolls element into view before capturing.
take_screenshot
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
async def click_using_js(self): """ Click element using JavaScript click() method. Raises: ElementNotVisible: If element is not visible. ElementNotInteractable: If element couldn't be clicked. Note: For <option> elements, uses specialized selection a...
Click element using JavaScript click() method. Raises: ElementNotVisible: If element is not visible. ElementNotInteractable: If element couldn't be clicked. Note: For <option> elements, uses specialized selection approach. Element is automatical...
click_using_js
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
async def click( self, x_offset: int = 0, y_offset: int = 0, hold_time: float = 0.1, ): """ Click element using simulated mouse events. Args: x_offset: Horizontal offset from element center. y_offset: Vertical offset from element cente...
Click element using simulated mouse events. Args: x_offset: Horizontal offset from element center. y_offset: Vertical offset from element center. hold_time: Duration to hold mouse button down. Raises: ElementNotVisible: If element is not visible...
click
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
async def insert_text(self, text: str): """ Insert text in single operation (faster but less realistic than typing). Note: Element should already be focused for text to be inserted correctly. """ await self._execute_command(InputCommands.insert_text(text))
Insert text in single operation (faster but less realistic than typing). Note: Element should already be focused for text to be inserted correctly.
insert_text
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
async def set_input_files(self, files: list[str]): """ Set file paths for file input element. Args: files: list of absolute file paths to existing files. Raises: ElementNotAFileInput: If element is not a file input. """ if ( self._att...
Set file paths for file input element. Args: files: list of absolute file paths to existing files. Raises: ElementNotAFileInput: If element is not a file input.
set_input_files
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
async def type_text(self, text: str, interval: float = 0.1): """ Type text character by character with realistic timing. More realistic than insert_text() but slower. """ for char in text: await self._execute_command( InputCommands.dispatch_key_event(...
Type text character by character with realistic timing. More realistic than insert_text() but slower.
type_text
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
async def key_down(self, key: Key, modifiers: Optional[KeyModifier] = None): """ Send key down event. Note: Only sends key down without release. Pair with key_up() for complete keypress. """ key_name, code = key await self._execute_command( InputC...
Send key down event. Note: Only sends key down without release. Pair with key_up() for complete keypress.
key_down
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
async def key_up(self, key: Key): """Send key up event (should follow corresponding key_down()).""" key_name, code = key await self._execute_command( InputCommands.dispatch_key_event( type=KeyEventType.KEY_UP, key=key_name, windows_virt...
Send key up event (should follow corresponding key_down()).
key_up
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
async def press_keyboard_key( self, key: Key, modifiers: Optional[KeyModifier] = None, interval: float = 0.1, ): """ Press and release keyboard key with configurable timing. Better for special keys (Enter, Tab, etc.) than type_text(). """ awai...
Press and release keyboard key with configurable timing. Better for special keys (Enter, Tab, etc.) than type_text().
press_keyboard_key
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
async def _click_option_tag(self): """Specialized method for clicking <option> elements in dropdowns.""" script = Scripts.CLICK_OPTION_TAG.replace('{self.value}', self.value) await self._execute_command(RuntimeCommands.evaluate(script))
Specialized method for clicking <option> elements in dropdowns.
_click_option_tag
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
async def _is_element_visible(self): """Check if element is visible using comprehensive JavaScript visibility test.""" result = await self._execute_script(Scripts.ELEMENT_VISIBLE, return_by_value=True) return result['result']['result']['value']
Check if element is visible using comprehensive JavaScript visibility test.
_is_element_visible
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
async def _is_element_on_top(self): """Check if element is topmost at its center point (not covered by overlays).""" result = await self._execute_script(Scripts.ELEMENT_ON_TOP, return_by_value=True) return result['result']['result']['value']
Check if element is topmost at its center point (not covered by overlays).
_is_element_on_top
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
async def _execute_script(self, script: str, return_by_value: bool = False): """ Execute JavaScript in element context. Element is available as 'this' within the script. """ return await self._execute_command( RuntimeCommands.call_function_on( object_...
Execute JavaScript in element context. Element is available as 'this' within the script.
_execute_script
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
def _def_attributes(self, attributes_list: list[str]): """Process flat attribute list into dictionary (renames 'class' to 'class_name').""" for i in range(0, len(attributes_list), 2): key = attributes_list[i] key = key if key != 'class' else 'class_name' value = attri...
Process flat attribute list into dictionary (renames 'class' to 'class_name').
_def_attributes
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
def _calculate_center(bounds: list) -> tuple: """Calculate center point from bounding box coordinates.""" x_values = [bounds[i] for i in range(0, len(bounds), 2)] y_values = [bounds[i] for i in range(1, len(bounds), 2)] x_center = sum(x_values) / len(x_values) y_center = sum(y_va...
Calculate center point from bounding box coordinates.
_calculate_center
python
autoscrape-labs/pydoll
pydoll/elements/web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/web_element.py
MIT
def create_web_element(*args, **kwargs): """ Create WebElement instance avoiding circular imports. Factory method that dynamically imports WebElement at runtime to prevent circular import dependencies. """ from pydoll.elements.web_element import WebElement # noqa: PLC0415 return WebElemen...
Create WebElement instance avoiding circular imports. Factory method that dynamically imports WebElement at runtime to prevent circular import dependencies.
create_web_element
python
autoscrape-labs/pydoll
pydoll/elements/mixins/find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/mixins/find_elements_mixin.py
MIT
async def find( # noqa: PLR0913, PLR0917 self, id: Optional[str] = None, class_name: Optional[str] = None, name: Optional[str] = None, tag_name: Optional[str] = None, text: Optional[str] = None, timeout: int = 0, find_all: bool = False, raise_exc:...
Find element(s) using combination of common HTML attributes. Flexible element location using standard attributes. Multiple attributes can be combined for specific selectors (builds XPath when multiple specified). Args: id: Element ID attribute value. class_name...
find
python
autoscrape-labs/pydoll
pydoll/elements/mixins/find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/mixins/find_elements_mixin.py
MIT
async def query( self, expression: str, timeout: int = 0, find_all: bool = False, raise_exc: bool = True ) -> Union['WebElement', list['WebElement'], None]: """ Find element(s) using raw CSS selector or XPath expression. Direct access using CSS or XPath syntax. Selector type automat...
Find element(s) using raw CSS selector or XPath expression. Direct access using CSS or XPath syntax. Selector type automatically determined based on expression pattern. Args: expression: Selector expression (CSS, XPath, ID with #, class with .). timeout: Maximu...
query
python
autoscrape-labs/pydoll
pydoll/elements/mixins/find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/mixins/find_elements_mixin.py
MIT
async def find_or_wait_element( self, by: By, value: str, timeout: int = 0, find_all: bool = False, raise_exc: bool = True, ) -> Union['WebElement', list['WebElement'], None]: """ Core element finding method with optional waiting capability. S...
Core element finding method with optional waiting capability. Searches for elements with flexible waiting. If timeout specified, repeatedly attempts to find elements with 0.5s delays until success or timeout. Used by higher-level find() and query() methods. Args: b...
find_or_wait_element
python
autoscrape-labs/pydoll
pydoll/elements/mixins/find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/mixins/find_elements_mixin.py
MIT
async def _find_element( self, by: By, value: str, raise_exc: bool = True ) -> Optional['WebElement']: """ Find first element matching selector. Internal method performing actual element search. Can be called directly for fine-grained control. Searches in document context or...
Find first element matching selector. Internal method performing actual element search. Can be called directly for fine-grained control. Searches in document context or relative to current element (when used from WebElement). Args: by: Selector strategy (CSS_SELECT...
_find_element
python
autoscrape-labs/pydoll
pydoll/elements/mixins/find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/mixins/find_elements_mixin.py
MIT
async def _find_elements( self, by: By, value: str, raise_exc: bool = True ) -> list['WebElement']: """ Find all elements matching selector. Internal method performing actual multi-element search. Can be called directly for fine-grained control. Searches in document context ...
Find all elements matching selector. Internal method performing actual multi-element search. Can be called directly for fine-grained control. Searches in document context or relative to current element (when used from WebElement). Args: by: Selector strategy (CSS_S...
_find_elements
python
autoscrape-labs/pydoll
pydoll/elements/mixins/find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/mixins/find_elements_mixin.py
MIT
def _get_by_and_value( # noqa: PLR0913, PLR0917 self, by_map: dict[str, By], id: Optional[str] = None, class_name: Optional[str] = None, name: Optional[str] = None, tag_name: Optional[str] = None, text: Optional[str] = None, **attributes, ) -> tuple[B...
Determine appropriate selector strategy and value from provided arguments. For single attribute: uses direct selector strategy. For multiple attributes: builds XPath expression.
_get_by_and_value
python
autoscrape-labs/pydoll
pydoll/elements/mixins/find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/mixins/find_elements_mixin.py
MIT
def _build_xpath( id: Optional[str] = None, class_name: Optional[str] = None, name: Optional[str] = None, tag_name: Optional[str] = None, text: Optional[str] = None, **attributes, ) -> str: """ Build XPath expression from multiple attribute criteria. ...
Build XPath expression from multiple attribute criteria. Constructs complex XPath combining multiple conditions with 'and' operators. Handles class names correctly for space-separated class lists. Uses contains() for text matching (partial text support).
_build_xpath
python
autoscrape-labs/pydoll
pydoll/elements/mixins/find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/mixins/find_elements_mixin.py
MIT
def _get_expression_type(expression: str) -> By: """ Auto-detect selector type from expression syntax. Patterns: - XPath: starts with //, .// , ./, or / - ID: starts with # - Class: starts with . (but not ./) - Default: CSS_SELECTOR """ xpath_patt...
Auto-detect selector type from expression syntax. Patterns: - XPath: starts with //, .// , ./, or / - ID: starts with # - Class: starts with . (but not ./) - Default: CSS_SELECTOR
_get_expression_type
python
autoscrape-labs/pydoll
pydoll/elements/mixins/find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/mixins/find_elements_mixin.py
MIT
async def _describe_node(self, object_id: str = '') -> Node: """ Get detailed DOM node information using CDP DOM.describeNode. Used internally to gather data for WebElement initialization. """ response: DescribeNodeResponse = await self._execute_command( DomCommands....
Get detailed DOM node information using CDP DOM.describeNode. Used internally to gather data for WebElement initialization.
_describe_node
python
autoscrape-labs/pydoll
pydoll/elements/mixins/find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/mixins/find_elements_mixin.py
MIT
async def _execute_command(self, command: Command[T]) -> T: """Execute CDP command via connection handler (60s timeout).""" return await self._connection_handler.execute_command(command, timeout=60) # type: ignore
Execute CDP command via connection handler (60s timeout).
_execute_command
python
autoscrape-labs/pydoll
pydoll/elements/mixins/find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/mixins/find_elements_mixin.py
MIT
def _get_find_element_command(self, by: By, value: str, object_id: str = ''): """ Create CDP command for finding single element. Handles special cases for different selector types and contexts: - CLASS_NAME/ID: converts to CSS selector - Relative searches: uses different scripts...
Create CDP command for finding single element. Handles special cases for different selector types and contexts: - CLASS_NAME/ID: converts to CSS selector - Relative searches: uses different scripts for context element - XPath: requires special handling - NAME: converts ...
_get_find_element_command
python
autoscrape-labs/pydoll
pydoll/elements/mixins/find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/mixins/find_elements_mixin.py
MIT
def _get_find_elements_command(self, by: By, value: str, object_id: str = ''): """ Create CDP command for finding multiple elements. Similar to _get_find_element_command but for multiple element searches. Handles same special cases and selector type conversions. """ esca...
Create CDP command for finding multiple elements. Similar to _get_find_element_command but for multiple element searches. Handles same special cases and selector type conversions.
_get_find_elements_command
python
autoscrape-labs/pydoll
pydoll/elements/mixins/find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/mixins/find_elements_mixin.py
MIT
def _get_find_element_by_xpath_command(self, xpath: str, object_id: str): """ Create CDP command specifically for XPath single element finding. XPath requires special handling vs CSS selectors. Ensures relative XPath for context-based searches. """ escaped_value = xpath....
Create CDP command specifically for XPath single element finding. XPath requires special handling vs CSS selectors. Ensures relative XPath for context-based searches.
_get_find_element_by_xpath_command
python
autoscrape-labs/pydoll
pydoll/elements/mixins/find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/mixins/find_elements_mixin.py
MIT
def _get_find_elements_by_xpath_command(self, xpath: str, object_id: str): """ Create CDP command specifically for XPath multiple element finding. XPath requires special handling vs CSS selectors. Ensures relative XPath for context-based searches. """ escaped_value = xpa...
Create CDP command specifically for XPath multiple element finding. XPath requires special handling vs CSS selectors. Ensures relative XPath for context-based searches.
_get_find_elements_by_xpath_command
python
autoscrape-labs/pydoll
pydoll/elements/mixins/find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/pydoll/elements/mixins/find_elements_mixin.py
MIT
def test_event_enums_integrity(): """Test that all event enums are properly structured and have no duplicates.""" # Test that all enums inherit from str and Enum event_classes = [ BrowserEvent, DomEvent, FetchEvent, InputEvent, NetworkEvent, PageEvent, RuntimeEvent, StorageEvent, TargetEvent...
Test that all event enums are properly structured and have no duplicates.
test_event_enums_integrity
python
autoscrape-labs/pydoll
tests/test_events.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_events.py
MIT
def test_no_duplicate_events(): """Test that there are no duplicate event values across all enums.""" all_events = [] event_classes = [ BrowserEvent, DomEvent, FetchEvent, InputEvent, NetworkEvent, PageEvent, RuntimeEvent, StorageEvent, TargetEvent ] for event_class in event_classe...
Test that there are no duplicate event values across all enums.
test_no_duplicate_events
python
autoscrape-labs/pydoll
tests/test_events.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_events.py
MIT
def test_event_enum_completeness(): """Test that each event enum has at least one event defined.""" event_classes = [ BrowserEvent, DomEvent, FetchEvent, InputEvent, NetworkEvent, PageEvent, RuntimeEvent, StorageEvent, TargetEvent ] for event_class in event_classes: assert l...
Test that each event enum has at least one event defined.
test_event_enum_completeness
python
autoscrape-labs/pydoll
tests/test_events.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_events.py
MIT
def test_event_naming_convention(): """Test that all event names follow the correct naming convention.""" event_classes = [ BrowserEvent, DomEvent, FetchEvent, InputEvent, NetworkEvent, PageEvent, RuntimeEvent, StorageEvent, TargetEvent ] for event_class in event_classes: for ev...
Test that all event names follow the correct naming convention.
test_event_naming_convention
python
autoscrape-labs/pydoll
tests/test_events.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_events.py
MIT
def test_all_exceptions_inherit_from_pydoll_exception(self): """Test that all custom exceptions inherit from PydollException.""" exceptions_to_test = [ ConnectionFailed, ReconnectionFailed, WebSocketConnectionClosed, NetworkError, BrowserNotRunning, FailedToStartBrowser, Unsuppor...
Test that all custom exceptions inherit from PydollException.
test_all_exceptions_inherit_from_pydoll_exception
python
autoscrape-labs/pydoll
tests/test_exceptions.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_exceptions.py
MIT
def test_base_exception_categories(self): """Test that base exception categories inherit from PydollException.""" base_exceptions = [ ConnectionException, BrowserException, ProtocolException, ElementException, TimeoutException, ConfigurationException, DialogException ] ...
Test that base exception categories inherit from PydollException.
test_base_exception_categories
python
autoscrape-labs/pydoll
tests/test_exceptions.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_exceptions.py
MIT
def test_connection_exceptions_inherit_from_connection_exception(self): """Test that connection exceptions inherit from ConnectionException.""" connection_exceptions = [ConnectionFailed, ReconnectionFailed, WebSocketConnectionClosed, NetworkError] for exception_class in connection_excep...
Test that connection exceptions inherit from ConnectionException.
test_connection_exceptions_inherit_from_connection_exception
python
autoscrape-labs/pydoll
tests/test_exceptions.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_exceptions.py
MIT
def test_build_xpath_single_id(self): """Test XPath building with only ID.""" xpath = FindElementsMixin._build_xpath(id='test-id') assert xpath == '//*[@id="test-id"]'
Test XPath building with only ID.
test_build_xpath_single_id
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_build_xpath_single_class_name(self): """Test XPath building with only class name.""" xpath = FindElementsMixin._build_xpath(class_name='btn-primary') expected = '//*[contains(concat(" ", normalize-space(@class), " "), " btn-primary ")]' assert xpath == expected
Test XPath building with only class name.
test_build_xpath_single_class_name
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_build_xpath_single_name(self): """Test XPath building with only name attribute.""" xpath = FindElementsMixin._build_xpath(name='username') assert xpath == '//*[@name="username"]'
Test XPath building with only name attribute.
test_build_xpath_single_name
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_build_xpath_single_tag_name(self): """Test XPath building with only tag name.""" xpath = FindElementsMixin._build_xpath(tag_name='button') assert xpath == '//button'
Test XPath building with only tag name.
test_build_xpath_single_tag_name
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_build_xpath_single_text(self): """Test XPath building with only text content.""" xpath = FindElementsMixin._build_xpath(text='Click me') assert xpath == '//*[contains(text(), "Click me")]'
Test XPath building with only text content.
test_build_xpath_single_text
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_build_xpath_single_custom_attribute(self): """Test XPath building with single custom attribute.""" xpath = FindElementsMixin._build_xpath(data_testid='submit-btn') assert xpath == '//*[@data_testid="submit-btn"]'
Test XPath building with single custom attribute.
test_build_xpath_single_custom_attribute
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_build_xpath_id_and_class(self): """Test XPath building with ID and class name.""" xpath = FindElementsMixin._build_xpath(id='main-btn', class_name='primary') expected = '//*[@id="main-btn" and contains(concat(" ", normalize-space(@class), " "), " primary ")]' assert xpath == exp...
Test XPath building with ID and class name.
test_build_xpath_id_and_class
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_build_xpath_tag_and_attributes(self): """Test XPath building with tag name and multiple attributes.""" xpath = FindElementsMixin._build_xpath( tag_name='input', id='email-field', name='email', type='email' ) expected = '//input[@id...
Test XPath building with tag name and multiple attributes.
test_build_xpath_tag_and_attributes
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_build_xpath_all_parameters(self): """Test XPath building with all possible parameters.""" xpath = FindElementsMixin._build_xpath( id='complex-element', class_name='form-control', name='user_input', tag_name='input', text='placeholder t...
Test XPath building with all possible parameters.
test_build_xpath_all_parameters
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_build_xpath_text_with_quotes(self): """Test XPath building with text containing quotes.""" xpath = FindElementsMixin._build_xpath(text='Say "Hello"') assert xpath == '//*[contains(text(), "Say "Hello"")]'
Test XPath building with text containing quotes.
test_build_xpath_text_with_quotes
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_build_xpath_attribute_with_quotes(self): """Test XPath building with attribute value containing quotes.""" xpath = FindElementsMixin._build_xpath(title='This is a "quoted" title') assert xpath == '//*[@title="This is a "quoted" title"]'
Test XPath building with attribute value containing quotes.
test_build_xpath_attribute_with_quotes
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_build_xpath_empty_values_ignored(self): """Test that empty string values are ignored in XPath building.""" xpath = FindElementsMixin._build_xpath( id='test-id', class_name='', # Empty string should be ignored name=None, # None should be ignored ...
Test that empty string values are ignored in XPath building.
test_build_xpath_empty_values_ignored
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_build_xpath_class_name_with_spaces(self): """Test XPath building with class name that has spaces (edge case).""" xpath = FindElementsMixin._build_xpath(class_name='btn primary large') expected = '//*[contains(concat(" ", normalize-space(@class), " "), " btn primary large ")]' as...
Test XPath building with class name that has spaces (edge case).
test_build_xpath_class_name_with_spaces
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_build_xpath_special_characters_in_attributes(self): """Test XPath building with special characters in attribute values.""" xpath = FindElementsMixin._build_xpath( data_value='test@example.com', aria_describedby='field-help-123' ) expected = '//*[@data_val...
Test XPath building with special characters in attribute values.
test_build_xpath_special_characters_in_attributes
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_build_xpath_numeric_attribute_values(self): """Test XPath building with numeric attribute values.""" xpath = FindElementsMixin._build_xpath( tabindex='0', maxlength='255' ) expected = '//*[@tabindex="0" and @maxlength="255"]' assert xpath == expec...
Test XPath building with numeric attribute values.
test_build_xpath_numeric_attribute_values
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_build_xpath_no_parameters(self): """Test XPath building with no parameters returns generic selector.""" xpath = FindElementsMixin._build_xpath() assert xpath == '//*'
Test XPath building with no parameters returns generic selector.
test_build_xpath_no_parameters
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_build_xpath_hyphenated_attributes(self): """Test XPath building with hyphenated attribute names.""" xpath = FindElementsMixin._build_xpath( **{'data-test-id': 'submit-button', 'aria-label': 'Submit form'} ) expected = '//*[@data-test-id="submit-button" and @aria-labe...
Test XPath building with hyphenated attribute names.
test_build_xpath_hyphenated_attributes
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_class_selector_not_xpath(self): """Test that class selector doesn't conflict with XPath dot slash.""" assert FindElementsMixin._get_expression_type('.button') == By.CLASS_NAME assert FindElementsMixin._get_expression_type('./button') == By.XPATH
Test that class selector doesn't conflict with XPath dot slash.
test_class_selector_not_xpath
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_complex_xpath_expressions(self): """Test complex XPath expressions are detected correctly.""" complex_xpaths = [ '//div[@class="content"]/p[contains(text(), "Hello")]', './/button[position()=1]', './/*[@id="test" and @class="active"]', '/html/body...
Test complex XPath expressions are detected correctly.
test_complex_xpath_expressions
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_absolute_xpath_becomes_relative(self): """Test that absolute XPath becomes relative.""" xpath = '//div[@id="test"]' result = FindElementsMixin._ensure_relative_xpath(xpath) assert result == './/div[@id="test"]'
Test that absolute XPath becomes relative.
test_absolute_xpath_becomes_relative
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_already_relative_xpath_unchanged(self): """Test that already relative XPath remains unchanged.""" xpath = './/div[@id="test"]' result = FindElementsMixin._ensure_relative_xpath(xpath) assert result == './/div[@id="test"]'
Test that already relative XPath remains unchanged.
test_already_relative_xpath_unchanged
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_dot_slash_xpath_unchanged(self): """Test that dot slash XPath remains unchanged.""" xpath = './button' result = FindElementsMixin._ensure_relative_xpath(xpath) assert result == './button'
Test that dot slash XPath remains unchanged.
test_dot_slash_xpath_unchanged
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_single_slash_xpath_becomes_relative(self): """Test that single slash XPath becomes relative.""" xpath = '/html/body/div' result = FindElementsMixin._ensure_relative_xpath(xpath) assert result == './html/body/div'
Test that single slash XPath becomes relative.
test_single_slash_xpath_becomes_relative
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_single_id_selector(self): """Test single ID selector returns direct By.ID.""" by, value = self.mixin._get_by_and_value(self.by_map, id='test-id') assert by == By.ID assert value == 'test-id'
Test single ID selector returns direct By.ID.
test_single_id_selector
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_single_class_name_selector(self): """Test single class name selector returns direct By.CLASS_NAME.""" by, value = self.mixin._get_by_and_value(self.by_map, class_name='btn-primary') assert by == By.CLASS_NAME assert value == 'btn-primary'
Test single class name selector returns direct By.CLASS_NAME.
test_single_class_name_selector
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_single_name_selector(self): """Test single name selector returns direct By.NAME.""" by, value = self.mixin._get_by_and_value(self.by_map, name='username') assert by == By.NAME assert value == 'username'
Test single name selector returns direct By.NAME.
test_single_name_selector
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_single_tag_name_selector(self): """Test single tag name selector returns direct By.TAG_NAME.""" by, value = self.mixin._get_by_and_value(self.by_map, tag_name='button') assert by == By.TAG_NAME assert value == 'button'
Test single tag name selector returns direct By.TAG_NAME.
test_single_tag_name_selector
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_single_custom_attribute(self): """Test single custom attribute builds XPath.""" by, value = self.mixin._get_by_and_value(self.by_map, data_testid='submit-btn') assert by == By.XPATH assert value == '//*[@data_testid="submit-btn"]'
Test single custom attribute builds XPath.
test_single_custom_attribute
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_text_with_single_attribute_builds_xpath(self): """Test that text with any other attribute builds XPath.""" by, value = self.mixin._get_by_and_value( self.by_map, id='test-id', text='Click me' ) assert by == By.XPATH expected = '//*[@id...
Test that text with any other attribute builds XPath.
test_text_with_single_attribute_builds_xpath
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_text_alone_builds_xpath(self): """Test that text alone builds XPath.""" by, value = self.mixin._get_by_and_value(self.by_map, text='Submit') assert by == By.XPATH assert value == '//*[contains(text(), "Submit")]'
Test that text alone builds XPath.
test_text_alone_builds_xpath
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_empty_values_ignored(self): """Test that empty values are ignored in selector building.""" by, value = self.mixin._get_by_and_value( self.by_map, id='test-id', class_name='', # Empty string name=None # None value ) assert by...
Test that empty values are ignored in selector building.
test_empty_values_ignored
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_all_empty_values_with_custom_attribute(self): """Test custom attribute when standard attributes are empty.""" by, value = self.mixin._get_by_and_value( self.by_map, id='', class_name=None, data_role='button' ) assert by == By.XPATH...
Test custom attribute when standard attributes are empty.
test_all_empty_values_with_custom_attribute
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
async def test_find_no_criteria_raises_error(self): """Test that find with no criteria raises ValueError.""" with pytest.raises(ValueError, match='At least one of the following arguments must be provided'): await self.mixin.find()
Test that find with no criteria raises ValueError.
test_find_no_criteria_raises_error
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
async def test_find_empty_string_criteria_raises_error(self): """Test that find with only empty string criteria raises ValueError.""" with pytest.raises(ValueError, match='At least one of the following arguments must be provided'): await self.mixin.find(id='', class_name='', name='', tag_nam...
Test that find with only empty string criteria raises ValueError.
test_find_empty_string_criteria_raises_error
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
async def test_find_none_criteria_raises_error(self): """Test that find with only None criteria raises ValueError.""" with pytest.raises(ValueError, match='At least one of the following arguments must be provided'): await self.mixin.find(id=None, class_name=None, name=None, tag_name=None, te...
Test that find with only None criteria raises ValueError.
test_find_none_criteria_raises_error
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
async def test_find_with_custom_attributes_only(self): """Test find with only custom attributes works.""" # Mock the internal methods self.mixin._find_element = AsyncMock(return_value=MagicMock()) result = await self.mixin.find(data_testid='submit-button') # Sho...
Test find with only custom attributes works.
test_find_with_custom_attributes_only
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
async def test_find_or_wait_element_timeout_zero(self): """Test find_or_wait_element with timeout=0 calls find immediately.""" self.mixin._find_element = AsyncMock(return_value=MagicMock()) result = await self.mixin.find_or_wait_element(By.ID, 'test-id', timeout=0) self...
Test find_or_wait_element with timeout=0 calls find immediately.
test_find_or_wait_element_timeout_zero
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
async def test_find_or_wait_element_timeout_success_on_retry(self): """Test find_or_wait_element succeeds on retry within timeout.""" # First call returns None, second call returns element mock_element = MagicMock() self.mixin._find_element = AsyncMock(side_effect=[None, mock_element]) ...
Test find_or_wait_element succeeds on retry within timeout.
test_find_or_wait_element_timeout_success_on_retry
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
async def test_find_elements_with_timeout(self): """Test find with find_all=True and timeout.""" mock_elements = [MagicMock(), MagicMock()] self.mixin._find_elements = AsyncMock(return_value=mock_elements) result = await self.mixin.find_or_wait_element( By.CLASS_NAME...
Test find with find_all=True and timeout.
test_find_elements_with_timeout
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_regex_pattern_in_get_expression_type(self): """Test the regex pattern used in _get_expression_type.""" xpath_pattern = r'^(//|\.//|\.\/|/)' # Test cases that should match xpath_expressions = [ '//div', './/span', './button', ...
Test the regex pattern used in _get_expression_type.
test_regex_pattern_in_get_expression_type
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_xpath_building_with_boolean_attributes(self): """Test XPath building with boolean-like attributes.""" xpath = FindElementsMixin._build_xpath( required='true', disabled='false', checked='checked' ) expected = '//*[@required="true" and @disabled...
Test XPath building with boolean-like attributes.
test_xpath_building_with_boolean_attributes
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_xpath_building_preserves_attribute_order(self): """Test that XPath building maintains consistent attribute order.""" # Test multiple times to ensure consistency for _ in range(5): xpath = FindElementsMixin._build_xpath( id='test', class_name='...
Test that XPath building maintains consistent attribute order.
test_xpath_building_preserves_attribute_order
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_class_name_xpath_normalization(self): """Test that class name XPath uses proper normalization.""" xpath = FindElementsMixin._build_xpath(class_name='test-class') # Should use normalize-space to handle multiple spaces assert 'normalize-space(@class)' in xpath # S...
Test that class name XPath uses proper normalization.
test_class_name_xpath_normalization
python
autoscrape-labs/pydoll
tests/test_find_elements_mixin.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_find_elements_mixin.py
MIT
def test_decode_image_to_bytes(self): """ Test the decode_base64_to_bytes function. Verifies that the function correctly decodes a base64 string to its original bytes. """ base64code = 'aGVsbG8gd29ybGQ=' # 'hello world' in base64 assert decode_base64_to_bytes(bas...
Test the decode_base64_to_bytes function. Verifies that the function correctly decodes a base64 string to its original bytes.
test_decode_image_to_bytes
python
autoscrape-labs/pydoll
tests/test_utils.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_utils.py
MIT
def test_decode_image_to_bytes_complex_data(self): """ Test decode_base64_to_bytes with more complex base64 data. Verifies that the function can handle longer, more complex encoded data. """ # Base64 for "The quick brown fox jumps over the lazy dog" base64code = 'VGhlIHF1...
Test decode_base64_to_bytes with more complex base64 data. Verifies that the function can handle longer, more complex encoded data.
test_decode_image_to_bytes_complex_data
python
autoscrape-labs/pydoll
tests/test_utils.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_utils.py
MIT
async def test_successful_response(self): """ Test successful scenario when getting browser WebSocket address. Verifies that the function correctly returns the WebSocket URL when the API response contains the expected field. """ port = 9222 expected_url = 'ws://lo...
Test successful scenario when getting browser WebSocket address. Verifies that the function correctly returns the WebSocket URL when the API response contains the expected field.
test_successful_response
python
autoscrape-labs/pydoll
tests/test_utils.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_utils.py
MIT
async def test_network_error(self): """ Test behavior when a network error occurs. Verifies that the function raises the appropriate NetworkError exception when there's a communication failure with the browser. """ port = 9222 with pytest.raises(exceptions.Networ...
Test behavior when a network error occurs. Verifies that the function raises the appropriate NetworkError exception when there's a communication failure with the browser.
test_network_error
python
autoscrape-labs/pydoll
tests/test_utils.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_utils.py
MIT
async def test_missing_websocket_url(self): """ Test behavior when API response doesn't contain WebSocket URL. Verifies that the function raises InvalidResponse exception when the 'webSocketDebuggerUrl' field is missing from the response. """ port = 9222 with aio...
Test behavior when API response doesn't contain WebSocket URL. Verifies that the function raises InvalidResponse exception when the 'webSocketDebuggerUrl' field is missing from the response.
test_missing_websocket_url
python
autoscrape-labs/pydoll
tests/test_utils.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_utils.py
MIT
async def test_http_error_status(self): """ Test behavior when HTTP request returns an error status. Verifies that the function raises NetworkError when the server returns an HTTP error status code. """ port = 9222 with pytest.raises(exceptions.NetworkError): ...
Test behavior when HTTP request returns an error status. Verifies that the function raises NetworkError when the server returns an HTTP error status code.
test_http_error_status
python
autoscrape-labs/pydoll
tests/test_utils.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_utils.py
MIT
async def test_custom_port(self): """ Test get_browser_ws_address with a custom port. Verifies that the function works correctly with non-default ports. """ port = 9333 expected_url = 'ws://localhost:9333/devtools/browser/xyz789' with aioresponses() as mocked: ...
Test get_browser_ws_address with a custom port. Verifies that the function works correctly with non-default ports.
test_custom_port
python
autoscrape-labs/pydoll
tests/test_utils.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_utils.py
MIT
def test_validate_browser_paths_success(self): """ Test validate_browser_paths with valid executable path. Verifies that the function returns the first valid path found. """ with tempfile.TemporaryDirectory() as temp_dir: # Create a temporary executable file ...
Test validate_browser_paths with valid executable path. Verifies that the function returns the first valid path found.
test_validate_browser_paths_success
python
autoscrape-labs/pydoll
tests/test_utils.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_utils.py
MIT
def test_validate_browser_paths_first_valid_wins(self): """ Test that validate_browser_paths returns the first valid path. Verifies that when multiple valid paths exist, the first one is returned. """ with tempfile.TemporaryDirectory() as temp_dir: # Create two valid ...
Test that validate_browser_paths returns the first valid path. Verifies that when multiple valid paths exist, the first one is returned.
test_validate_browser_paths_first_valid_wins
python
autoscrape-labs/pydoll
tests/test_utils.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_utils.py
MIT
def test_validate_browser_paths_no_valid_paths(self): """ Test validate_browser_paths when no valid paths exist. Verifies that InvalidBrowserPath exception is raised when no executable browser is found in the provided paths. """ invalid_paths = [ '/nonexistent...
Test validate_browser_paths when no valid paths exist. Verifies that InvalidBrowserPath exception is raised when no executable browser is found in the provided paths.
test_validate_browser_paths_no_valid_paths
python
autoscrape-labs/pydoll
tests/test_utils.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_utils.py
MIT
def test_validate_browser_paths_file_exists_but_not_executable(self): """ Test validate_browser_paths with non-executable file. Verifies that a file that exists but is not executable is not considered valid. """ with tempfile.TemporaryDirectory() as temp_dir: # Create...
Test validate_browser_paths with non-executable file. Verifies that a file that exists but is not executable is not considered valid.
test_validate_browser_paths_file_exists_but_not_executable
python
autoscrape-labs/pydoll
tests/test_utils.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_utils.py
MIT
def test_validate_browser_paths_mixed_valid_invalid(self): """ Test validate_browser_paths with mix of valid and invalid paths. Verifies that the function skips invalid paths and returns the first valid one. """ with tempfile.TemporaryDirectory() as temp_dir: # Create...
Test validate_browser_paths with mix of valid and invalid paths. Verifies that the function skips invalid paths and returns the first valid one.
test_validate_browser_paths_mixed_valid_invalid
python
autoscrape-labs/pydoll
tests/test_utils.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_utils.py
MIT
async def mock_connection_handler(): """Mock connection handler for WebElement tests.""" with patch('pydoll.connection.ConnectionHandler', autospec=True) as mock: handler = mock.return_value handler.execute_command = AsyncMock() yield handler
Mock connection handler for WebElement tests.
mock_connection_handler
python
autoscrape-labs/pydoll
tests/test_web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_web_element.py
MIT
def web_element(mock_connection_handler): """Basic WebElement fixture with common attributes.""" attributes_list = [ 'id', 'test-id', 'class', 'test-class', 'value', 'test-value', 'tag_name', 'div', 'type', 'text' ] return WebElement( object_id='test-objec...
Basic WebElement fixture with common attributes.
web_element
python
autoscrape-labs/pydoll
tests/test_web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_web_element.py
MIT
def input_element(mock_connection_handler): """Input element fixture for form-related tests.""" attributes_list = [ 'id', 'input-id', 'tag_name', 'input', 'type', 'text', 'value', 'initial-value' ] return WebElement( object_id='input-object-id', connection...
Input element fixture for form-related tests.
input_element
python
autoscrape-labs/pydoll
tests/test_web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_web_element.py
MIT
def file_input_element(mock_connection_handler): """File input element fixture for file upload tests.""" attributes_list = [ 'id', 'file-input-id', 'tag_name', 'input', 'type', 'file' ] return WebElement( object_id='file-input-object-id', connection_handler=mock_c...
File input element fixture for file upload tests.
file_input_element
python
autoscrape-labs/pydoll
tests/test_web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_web_element.py
MIT
def option_element(mock_connection_handler): """Option element fixture for dropdown tests.""" attributes_list = [ 'tag_name', 'option', 'value', 'option-value', 'id', 'option-id' ] return WebElement( object_id='option-object-id', connection_handler=mock_connection...
Option element fixture for dropdown tests.
option_element
python
autoscrape-labs/pydoll
tests/test_web_element.py
https://github.com/autoscrape-labs/pydoll/blob/master/tests/test_web_element.py
MIT