繁体   English   中英

Selenium 发送密钥在 Ubuntu 上不起作用 /

[英]Selenium Send Keys not working on Ubuntu with /

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. 在 Windows 中,它们没有被删除。

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

最终结果是:sudo binbash

任何想法如何解决这个问题? 我已经尝试过 escaping 并且没有运气。

谢谢你的时间。

我尝试将其编码发送,但没有奏效。

我想出的方法是将值设置到剪贴板并使用 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")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM