Skip to content

execute_script() should have an element option to run on #12

@Adrian-Tamas

Description

@Adrian-Tamas

Hi,

Fist: I want to thank you for your hard work on this lib, it is awesome.

Regarding the issue:
execute_script() should have an element option in order to run code on that specific element. For example if I want to highlight the element during execution for debugging purposes using the default execute_script I can but using elementium it is harder.

Sample code (context.driver is just the driver created in the before_feature of the behave script):

browser = SeElements(context.driver)
browser.navigate("https://www.toolsqa.com/automation-practice-form/").insist(lambda e: "Demo Form" in e.title())
first_name = browser.find("input[name='firstname']", wait=True, ttl=context.timeout)
first_name.write("First Name")
script = "arguments[0].style.border='5px solid #6bf442'"

se_first_name = context.driver.find_element_by_css_selector("input[name='firstname']")
context.driver.execute_script(script, se_first_name)

first_name.execute_script(script=script)

Looking into the implementation of execute_script in se.py it is called directly on self.browser

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions