seleniumbase / SeleniumBase

📊 Blazing fast Python framework for web crawling, scraping, testing, and reporting. Supports pytest. Stealth abilities: UC Mode and CDP Mode.
https://seleniumbase.io
MIT License
5.38k stars 979 forks source link

wrong text in input with uc_gui_write / uc_gui_press_keys #3047

Closed Scooper54 closed 2 months ago

Scooper54 commented 2 months ago

When using uc_gui_press_keys or uc_gui_write with email like vjnyjhbcijsyghsjnt@poplk.com the result in my input is vjnyjhbcijsyghsjnt2poplk:co,

I'm on Apple M3

mdmintz commented 2 months ago

Make sure you're calling the methods correctly. Here's an example:

from seleniumbase import SB

with SB(uc=True, test=True) as sb:
    url = "https://seleniumbase.io/antibot/login"
    sb.uc_open_with_disconnect(url, 2.15)
    sb.uc_gui_write("\t" + "demo_user")
    sb.uc_gui_write("\t" + "secret_pass")
    sb.uc_gui_press_keys("\t" + " ")  # For Single-char keys
    sb.sleep(1.5)
    sb.uc_gui_press_keys(["\t", "ENTER"])  # Multi-char keys
    sb.reconnect(1.8)
    sb.assert_text("Welcome!", "h1")
    sb.set_messenger_theme(location="bottom_center")
    sb.post_message("SeleniumBase wasn't detected!")

I also tried with email addresses (with the @ symbol) and there was no issue there.

csmagyar commented 5 days ago

Hi! I encountered a similar issue while using any of these methods:

self.type(selector, text)
self.update_text(selector, text)
self.input(selector, text)
self.fill(selector, text)
self.write(selector, text)
self.send_keys(selector, text)
self.add_text(selector, text)
self.press_keys(selector, text)

I was trying to enter an email address into an input/textarea field, and instead of the @ symbol, it pasted the last copied text from my clipboard. It seems that the @ symbol is being treated as a wildcard, causing unexpected behavior.

Example:

from seleniumbase import SB

with SB(uc=True, incognito=True, maximize=True) as sb:
    url = "https://google.com"
    sb.uc_open_with_reconnect(url,4)

    # TEST <- Some text I recently copied to the clipboard

    sb.click("#L2AGLb") # Click to accept cookies
    sb.type("textarea[name='q']", "random@email.com") 
    sb.sleep(2)

I expected that the random@email.com text would be visible in the Google search bar, but instead, it is: randomTESTemail.com. Is there any solution to this?

mdmintz commented 5 days ago

Not seeing that issue. Maybe some weird localization for your browser where @ got converted into a paste command. What OS are you using? More info could help identify what's happening.