使用WebDriver找不到元素 [英] Can not find element using webdriver
本文介绍了使用WebDriver找不到元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有一个网络元素:
<select id="sel" onchange="refresh('sel')">
<option value="1"> A</option>
<option value="2"> B</option>
</select>
因为它具有onchange
,所以无法选择该选项.我的代码是这样的:
Because it has onchange
, I can not select the option. My code is like this:
new Select(driver.findElement(By.id("sel"))).selectByValue("1");
但是它不起作用.有可能使其工作吗?
But it can not work. Is it possible to make it to work?
推荐答案
使用xpath而不是id.因为按照代码,一旦您选择了值,它将刷新屏幕.尝试使用xpath,并在xpath给出一些刷新等待时间之后.
Use the xpath instead of using id. Because as per the code, it will refresh the screen once u select the value. Try using xpath and after the xpath give some wait period for refreshing.
这篇关于使用WebDriver找不到元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文