我想获得元素的文本。
这是禁用模式下拉框:
<select disabled="" readonly="readonly" onchange="onChange('incident.priority');" style="; " id="incident.priority" class="form-control readonly disabled" ng-non-bindable="true" name="incident.priority">
<option value="">-- None --</option>
<option value="1">1 - Critical</option>
<option value="2">2 - High</option>
<option value="3">3 - Moderate</option>
<option value="4">4 - Low</option>
<option value="5">5 - Planning</option>
</select>
我正在使用:
JavascriptExecutor jse = (JavascriptExecutor)driver;
WebElement element = driver.findElement(By.xpath("//select[@id='incident.priority']"));
String s = (String) jse.executeScript("return arguments[0].text" + "", element);
System.out.println("Priorityvalue= " + s);
输出为空。我想获得禁用元素文本。
答案 0 :(得分:0)
嗯,我不确定disabled属性将如何影响这一点,但在使用下拉框时,请使用IWebElement element = driver.FindElement(By.CssSelector("select[id='incident.priority']"));
SelectElement elementDdl = new SelectElement(element);
var text = elementDdl.SelectedOpiton.Text;
类。
var feedbackGenerator : UIImpactFeedbackGenerator? = nil
func performFeedbackPattern() {
//create the feedback generator
feedbackGenerator = UIImpactFeedbackGenerator(style: .heavy)
feedbackGenerator?.prepare()
//play the feedback three times with 1 second between each feedback
feedbackGenerator?.impactOccurred()
sleep (1)
feedbackGenerator?.impactOccurred()
sleep (1)
feedbackGenerator?.impactOccurred()
}
@IBAction func gestureRecognizer(_ sender: UILongPressGestureRecognizer) {
switch sender.state {
case .began:
performFeedbackPattern()
default: break
}
现在这是C#代码,但方法和类都应该以相似的方式命名。