0

I'm running Selenium using Python 3.6.4 and Pytest 6.1.1 on Ubuntu 20.04, when I run the below command to send keys the "/" are removed from the output. In Windows they are not removed.

element.send_keys("sudo /bin/bash")

The end result is: sudo binbash

Any ideas how to solve this problem? I've tried escaping them and no luck.

Thanks for your time.

2
  • Try sending it encoded Commented May 12, 2021 at 13:24
  • Add more details (link to site). Tested the same on google.com with Ubuntu 20.04 with no problems. Commented May 12, 2021 at 14:06

1 Answer 1

1

I tried sending it encoded and that didn't work.

What I came up with that worked was setting the value to the clip board and pasting it into the field using Ctrl + V.

from subprocess import PIPE, Popen        

p = Popen(["xsel", "-bi"], stdin=PIPE)
p.communicate(input=str.encode(text.strip()))
        
text_area = component.find_element_by_tag_name("textarea")
text_area.send_keys(Keys.CONTROL, "v")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.