python - Selenium 未向输入字段发送波浪字符 (~)

标签 python excel selenium

我正在创建一个从 Excel 工作表获取 URL 的应用程序,但它在 URL 中有波浪号('~')。当我使用 selenium 将其复制到输入字段时,该字符不会自行复制。

我遇到了 this去年的帖子,但没有人能解决这个问题。所以希望有人会知道答案:)

提前致谢!

#Fill in Discription
driver.find_element_by_xpath('//[@id="description"]').send_keys(Description)

最佳答案

这是我们的 friend @Mithun Mandal 在另一篇文章中所说的内容的表示(它在 C# 中,考虑到它是 selenium,转换为 python 应该不难)。

string url = "www.test~dummy.com";
foreach (string x in url.Split('~'))
{
    element.SendKeys(x);
    element.SendKeys("\u223C");
}
element.SendKeys(Keys.Backspace); //this is used to erase the wrong tilde typed at the end of the URL

Test

曾在这里工作。

关于python - Selenium 未向输入字段发送波浪字符 (~),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55816078/

相关文章:

python - 字符串和字节字符串有什么区别?

excel - 应用匹配功能如何复制粘贴数据

python - Selenium/xpath 从下拉菜单中获取文本

linux - Jenkins 和用于 selenium 脚本的 linux 机器

excel - 计划结束时间计算,考虑营业时间

python - 如何向 Selenium RC TestSuite 输入参数?

python - PySpark。将 Dataframe 传递给 pandas_udf 并返回一个系列

python - 对元组列表进行排序

python - #include <Python.h> Windows 10 修复没有这样的文件或目录

excel - 无法在 perl 中使用 Spreadsheet::ParseExcel 读取 Excel 2013 文件