Selenium没有向输入字段发送波浪号字符(~)

2024-05-18 16:17:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在创建一个应用程序,它从excel表中获取url,但是url中有一个波浪号('~')。当我将这个字符复制到带有selenium的输入字段时,它不会复制自身。在

我看到去年的一个帖子,但是没有人能解决这个问题。希望有人知道答案:)

提前谢谢!在

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


Tags: 答案in应用程序urlbydriverseleniumelement
2条回答

这是我们的朋友@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

在这里工作过。在

我是这样修好的。。在

在说明.替换(“~”、“\u223C”)

这对我有用:)

相关问题 更多 >

    热门问题