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

Cannot send characters directly to the browser #1147

Closed
LewisW opened this issue Mar 19, 2023 · 2 comments
Closed

Cannot send characters directly to the browser #1147

LewisW opened this issue Mar 19, 2023 · 2 comments

Comments

@LewisW
Copy link

LewisW commented Mar 19, 2023

The documentation implies that you can send keys directly to the browser, but the code expects an element name to be provided.

The result is an error like the following:
TypeError: BaseWebDriver.type() missing 1 required positional argument: 'value'

Is this something that's still supported?

@nameloCmaS
Copy link
Contributor

From what I understand, the way to do this is as below.

from selenium.webdriver.common.keys import Keys
from splinter import Browser
from splinter.driver import webdriver

browser = Browser("firefox")
browser.visit("https://github.com")
driver = browser.driver
actions = webdriver.ActionChains(driver)
# Queue for effect only. The first / brings up the search bar,
# the others type the search query in the search bar, followed by
# Enter to submit the form.
send_keys = ["/", "cobrateam", "/", "splinter", Keys.ENTER]
for send in send_keys:
    actions.send_keys(send)

actions.perform()

The function (implementation for web drivers) could be edited to run this code if no name argument is provided. But the function signature would not allow a default to just be set for name without value also having a default. Changing this would be a breaking change and affect some implementations.

More info from Stack Overflow.

Thus I agree, the documentation is misleading re this.

@LewisW
Copy link
Author

LewisW commented May 16, 2024

Awesome, thanks for clarifying.

@LewisW LewisW closed this as completed May 16, 2024
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

2 participants