【发布时间】:2017-08-14 01:23:35
【问题描述】:
<div class="form-control">
<label class="editor-property-label">Operation</label>
<select name="root[Donut][CenterLegend][Operation]">
<option value="Sum">Sum</option>
<option value="Percentage">Percentage</option>
</select>
</div>
我尝试了三种方法,但都失败了。
方法一:
IWebElement element= driver.findElement(By.cssSelector("select[name='root[Donut][CenterLegend][Operation]']"));
(IJavaScriptExecutor)driver.ExecuteScript("arguments[0].click()", element);
方法二:
IWebElement element= driver.findElement(By.cssSelector("label[class='editor-property-label']"));
(IJavaScriptExecutor)driver.ExecuteScript("document.elementFromPoint(" + element.Location.X +10 + "," + element.Location.Y + 10 + ").click();");
方法3:
IWebElement element= driver.findElement(By.cssSelector("select[name='root[Donut][CenterLegend][Operation]']"));
(IJavaScriptExecutor)driver.ExecuteScript("document.elementFromPoint(arguments[0],arguments[1]).click();"element.Location.X ,element.Location.Y);
【问题讨论】:
-
我无法单击
-
你使用
element.Click()然后如果你想通过文本选择new SelectElement(element).SelectByText(@"TEXT AAA"),如果你想通过值选择然后new SelectElement(element).SelectByValue(@"Value AAA")和new SelectElement(element).SelectByIndex(integerValue) -
我没有选择任何选项,我只需要单击
-
哦,所以只要 element.Click() 就足够了。试试吧 !我做到了!
-
(IJavaScriptExecutor)driver.ExecuteScript("arguments[0].style.border='2.5px orange solid';", element);我用它可以定位到
标签: javascript c# selenium