protractor - 在量角器中选择单选按钮
问题描述
我得到以下代码,如下所示:
<div class="inner">
<h1> SOme text here</h1>
<app-secondpart>
<div class="class2">
<label> some label</label>
<label>
<input id="yes" type="radio">
"Yes"
</label>
<label>
<input id="no" type="radio">
"No"
</label>
</div>
</app-secondpart>
</div>
我希望使用此代码“element(by.id("yes")).click();”选择/单击“是” 但是在运行应用程序时,我收到此错误“失败:元素不可交互”。
顺便说一下,我是 Protractor 的新手。
解决方案
试试下面的js点击按钮。
export async function jsClickButton() {
try {
let btn = element(By.id('yes'));
await browser.executeScript('arguments[0].click()', btn).then(async() => {
console.log('Btn has been clicked.');
});
} catch (error) {
console.log('Button is not clickable due ' + error);
}
}
- 第二种解决方案是单击标签元素。
推荐阅读
- bash - How can I merge two files by column with awk?
- selenium - Selenium Webdriver - 无法从 DropDown 打开和选择值
- mule - Mule Kafka Consumer - Pattern matching to filter messages
- arrays - 如何将 req.body 添加到 mongoose 数组?
- python - Adding a key with values to a dictionary
- ios - Carthage Access Token
- postgresql - 通过 postgresql 中的列引用表上的条目
- php - 使用 PHP 准备语句将数组插入 Postgres 数组
- ios - CurrentValueSubject 的属性包装器 - 内存管理
- javascript - 如何使用 NodeJS 中的公钥仅加密 JSON 有效负载的选定值?