RSelenium 点击元素 returns NULL
RSelenium clicking element returns NULL
我希望能够自动填写following test。在每个短语之后,您可以选择 Eens(我同意)或 Oneens(我不同意)。我正在使用 RSelenium 来执行此操作。
加载我的浏览器和第一个短语完全没有问题。但是,我不能 select 绿色或红色框。我正在使用以下代码:
choice_xpath <- "//*[contains(.,'Eens')]"
choice <- driver$findElement(using = "xpath",
choice_xpath)
choice$clickElement()
当我执行上面的代码时,返回 NULL。由于没有返回 'element not found' 错误,我想我正在单击一个存在但无法单击的元素。但如果是这样的话,我不知道该点击什么元素。
我认为这是html理解问题所需要的:
<script type="text/template" id="statements-tpl"></script>
<script type="text/template" id="statement-tpl">
<span class="prev-button"><span><</span></span>
<div class="copy">
<div class="copy-inner">{{ copy }}</div> </div>
<div class="button-wrap">
<div class="button-container">
<div class="button button-1">
</div>
</div>
<div class="button-container">
<div class="button button-0"></div>
</div>
<div class="button-container no-opinion">
<div class="button button-2"></div>
</div>
</div>
<span class="next-button"><span>></span></span>
</script>
<script type="text/template" id="button-tpl">
<div class="button-inner-wrapper">
<div class="button-inner{{ selected ? ' selected' : '' }}">
<div class="prefix">Jouw antwoord:</div>
<div class="copy"> {{% if ( type == 2 ) { %}} Geen mening {{% } else if ( type == 0 ) { %}} Oneens {{% } else { %}} Eens {{% } %}} </div>
<div class="error-tooltip"></div>
</div>
</div>
</script>
尝试使用下面的定位器来定位合适的元素:-
要找到 EENS(Agree)
按钮,请尝试:-
eens <- driver$findElement(using = "css selector", "div.button.button-1")
eens$clickElement()
要找到 ONEENS(DisAgree)
按钮,请尝试:-
oneens <- driver$findElement(using = "css selector", "div.button.button-2")
oneens$clickElement()
要找到 GEEN MENING(No Opinion)
按钮,请尝试:-
geenmeening <- driver$findElement(using = "css selector", "div.button.button-0")
geenmeening$clickElement()
我希望能够自动填写following test。在每个短语之后,您可以选择 Eens(我同意)或 Oneens(我不同意)。我正在使用 RSelenium 来执行此操作。
加载我的浏览器和第一个短语完全没有问题。但是,我不能 select 绿色或红色框。我正在使用以下代码:
choice_xpath <- "//*[contains(.,'Eens')]"
choice <- driver$findElement(using = "xpath",
choice_xpath)
choice$clickElement()
当我执行上面的代码时,返回 NULL。由于没有返回 'element not found' 错误,我想我正在单击一个存在但无法单击的元素。但如果是这样的话,我不知道该点击什么元素。
我认为这是html理解问题所需要的:
<script type="text/template" id="statements-tpl"></script>
<script type="text/template" id="statement-tpl">
<span class="prev-button"><span><</span></span>
<div class="copy">
<div class="copy-inner">{{ copy }}</div> </div>
<div class="button-wrap">
<div class="button-container">
<div class="button button-1">
</div>
</div>
<div class="button-container">
<div class="button button-0"></div>
</div>
<div class="button-container no-opinion">
<div class="button button-2"></div>
</div>
</div>
<span class="next-button"><span>></span></span>
</script>
<script type="text/template" id="button-tpl">
<div class="button-inner-wrapper">
<div class="button-inner{{ selected ? ' selected' : '' }}">
<div class="prefix">Jouw antwoord:</div>
<div class="copy"> {{% if ( type == 2 ) { %}} Geen mening {{% } else if ( type == 0 ) { %}} Oneens {{% } else { %}} Eens {{% } %}} </div>
<div class="error-tooltip"></div>
</div>
</div>
</script>
尝试使用下面的定位器来定位合适的元素:-
要找到
EENS(Agree)
按钮,请尝试:-eens <- driver$findElement(using = "css selector", "div.button.button-1") eens$clickElement()
要找到
ONEENS(DisAgree)
按钮,请尝试:-oneens <- driver$findElement(using = "css selector", "div.button.button-2") oneens$clickElement()
要找到
GEEN MENING(No Opinion)
按钮,请尝试:-geenmeening <- driver$findElement(using = "css selector", "div.button.button-0") geenmeening$clickElement()