elementium icon indicating copy to clipboard operation
elementium copied to clipboard

execute_script() should have an element option to run on

Open Adrian-Tamas opened this issue 6 years ago • 1 comments

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

Adrian-Tamas avatar Jul 22 '19 12:07 Adrian-Tamas

Hi,

I have created a PR on a fix for this: https://github.com/actmd/elementium/pull/13 adding an optional arguments parameter to be sent to the script.

Adrian-Tamas avatar Aug 07 '19 10:08 Adrian-Tamas