0
我試圖點擊一個單選按鈕,唯一的問題是我不斷收到錯誤'元素不可見'。我曾在這個網站上看過類似的問題,並嘗試了幾件事情,但沒有一件似乎有效。如何使元素可見,以便我可以點擊它?OpenQA.Selenium.ElementNotVisibleException:元素不可見c#硒
當代碼達到'allships.Click();'發生錯誤。我的頁面對象類:
public class MatchShipmentsToLocationsPage
{
//instance of the IWebDriver interface
private IWebDriver _driver;
//fields that are used to find the needed HTML elements for our tests to pass
private By lineItemTableLocator = By.Id("lineItemTable");
private By locationSearchInputBoxLocator = By.Id("locationSearch");
private By groupSearchLocationSearchLocator = By.CssSelector(".input-group.search.location-search");
private By applyLocationForLocator = By.Id("applyLocation");
private By justThisInvoiceRadioButtonLocator = By.Id("rbThisInvoice");
//constructor, constructs the the page
public MatchShipmentsToLocationsPage(IWebDriver driver)
{
this._driver = driver;
}
public MatchShipmentsToLocationsPage selectAllFutureShipmentsRadioButton()
{
var applyOptions = _driver.FindElement(applyLocationForLocator);
var allships = applyOptions.FindElements(By.Name("locationGroup"))[1];
allships.Click();
Thread.Sleep(5000);
return this;
}
}
的HTML:
<div id="applyLocation" class="panel-subsection">
<div class="panel-subsection-header">Allow for</div>
<div class="radio-button-section">
<div class="container radiocontainer">
::before
<input type="radio" checked="checked" name="locationGroup" id="rbThisInvoice">
<label for="rbThisInvoice">
<span class="radio inline radio-span radio-label">Just this invoice</span>
</label>
::after
</div>
<div class="container radiocontainer">
::before
<input type="radio" name="locationGroup" id="rbAllShipments">
<label for="rbAllShipments">
<span class="radio inline radio-span radio-label">
::before
All Future Shipments</span>
</label>
::after
</div>
</div>
</div>
如果你想出了一個解決方案,它張貼作爲一個答案並接受它,所以問題被標記爲已解決。 – JeffC
謝謝,只是做了@JeffC –