javascript - Selenium,如何按ENTER键,没有元素

标签 javascript html selenium web-scraping element

我正在使用 firefox selenium 插件,但我无法弄清楚在粘贴一些文本后发送回车键。 此 ENTER 按下是“不/不/不”在页面上的其他任何地方按下,即没有元素切换。 只需按下“哑”ENTER 键?

错误

[error] Element name=code not found

代码

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="https://www.facebook.com/" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
    <td>open</td>
    <td>/br.rall/posts/10153787412985552?comment_id=10153787988345552&amp;reply_comment_id=10153788588305552&amp;notif_t=feed_comment</td>
    <td></td>
</tr>
<tr>
    <td>type</td>
    <td>//div[@id='js_k']/div[5]/div/textarea</td>
    <td>In recent history, the phrase is most closely identified with critics of the economic policies known as &quot;Reaganomics&quot;. David Stockman, who as Reagan's budget director championed Reagan's tax cuts at first, but then became critical of them, told journalist William Greider that the &quot;supply-side economics&quot; is the trickle-down idea: &quot;It's kind of hard to sell 'trickle down,' so the supply-side formula was the only way to get a tax policy that was really 'trickle down.' Supply-side is 'trickle-down' theory.&quot;[4][5] Political opponents of the Reagan administration soon seized on this language in an effort to brand the administration as caring only about the wealthy.[6]</td>
</tr>
<tr>
       <td>sendKeys</td>
       <td></td>
       <td>${KEY_ENTER}</td>
</tr>

</tbody></table>
</body>
</html>

如何在“文本粘贴”后直接按 ENTER 键而不跳转元素?

最佳答案

您可以将 Enter 键发送到正文标记 - 因为每个页面都应该有一个,但它不应触发任何特定元素。

关于javascript - Selenium,如何按ENTER键,没有元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35087654/

相关文章:

javascript - 如何使用 knockout.js 单击时将数据从一个元素填充到另一个元素

java - 课前和课后不使用 Selenium Web 驱动程序

c# - Selenium - 等待网页请求外部 URL

c# - 使用动态列表c#验证xpath最后一个元素的数据

html - 两个不同的 div 之间有不需要的空间?

javascript - 将存储 RGBA 的 Uint8Array 数组保存到 .png 文件

javascript - 在 jquery 中选中复选框时启用确认框按钮

javascript - 无法在 this.setState() - React.js 中使用扩展运算符更新 json 属性

javascript - 选择选项后将下拉菜单切换为按钮?网页内

c# - 在 Google Visualization API (JavaScript) 中动态添加行