Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Adrian-Tamas opened this issue Jul 22, 2019 · 1 comment
Open

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

Adrian-Tamas opened this issue Jul 22, 2019 · 1 comment

Comments

@Adrian-Tamas
Copy link

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
Copy link
Author

Hi,

I have created a PR on a fix for this: #13 adding an optional arguments parameter to be sent to the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant