C# JS方面的专业知识。尝试等待元素不可见。WebDriverWait wait=新的WebDriverWait(webDriver,timeoutingseconds);wait.until(ExpectedConditions.visibilityOfEl
C# JS方面的专业知识。尝试等待元素不可见。WebDriverWait wait=新的WebDriverWait(webDriver,timeoutingseconds);wait.until(ExpectedConditions.visibilityOfEl,c#,selenium-webdriver,automation,C#,Selenium Webdriver,Automation,JS方面的专业知识。尝试等待元素不可见。WebDriverWait wait=新的WebDriverWait(webDriver,timeoutingseconds);wait.until(ExpectedConditions.visibilityOfElementLocated(By.XPath(//select[contains(@id,'.\uu TypeID')][2]); IWebElement selectType = driver.FindElement(B
JS方面的专业知识。尝试等待元素不可见。WebDriverWait wait=新的WebDriverWait(webDriver,timeoutingseconds);wait.until(ExpectedConditions.visibilityOfElementLocated(By.XPath(//select[contains(@id,'.\uu TypeID')][2]);
IWebElement selectType =
driver.FindElement(By.XPath("//select[@name='Entries[db9ef219-0f54-4925-9589-0f39351f44a4].TypeID']"));
selectType.Click();
IWebElement selectType = driver.FindElement(By.XPath("//select[contains(@id, '__TypeID')]"));
<div class="RegEffEntryContainer" xpath="1">
<div class="row">
<div class="col-11">
<input type="hidden" name="Entries.index" autocomplete="off" value="21b28f6b-8aaa-4924-815a-1d925585fa36">
<input data-val="true" data-val-number="The field EntryID must be a number." data-val-required="The EntryID field is required." id="Entries_21b28f6b-8aaa-4924-815a-1d925585fa36__EntryID" name="Entries[21b28f6b-8aaa-4924-815a-1d925585fa36].EntryID" type="hidden" value="391">
<div class="row">
<div class="col-12 col-sm-6 col-lg-3">
<div class="field-wrapper">
<select class="form-control valid" data-val="true" data-val-number="The field TypeID must be a number." id="Entries_21b28f6b-8aaa-4924-815a-1d925585fa36__TypeID" name="Entries[21b28f6b-8aaa-4924-815a-1d925585fa36].TypeID" required="" aria-describedby="Entries_21b28f6b-8aaa-4924-815a-1d925585fa36__TypeID-error" aria-invalid="false">
<option value="">Select type</option>
<option value="1">Regulatory Activity</option>
<option value="2">Major Project</option>
<option value="3">Other Activities</option>
</select><span class="asterisk">*</span>
</div>
</div>
IWebElement firstSelect = driver.FindElement(By.XPath("//select[contains(@id, '__TypeID')][1]"));
IWebElement secondSelect = driver.FindElement(By.XPath("//select[contains(@id, '__TypeID')][2]"));
IWebElement thirdSelect = driver.FindElement(By.XPath("//select[contains(@id, '__TypeID')][3]"));
int numberOfEntriesOnPage = System.Convert.ToInt32(((IJavaScriptExecutor)driver).ExecuteScript("return document.getElementsByName('Entries.index').length"));
string[] array = new string[numberOfEntriesOnPage];
for (int a = 0; a < numberOfEntriesOnPage; a++)
{
String script = "return document.getElementsByName('Entries.index')[" + a + "].value";
array[a] = ((IJavaScriptExecutor)driver).ExecuteScript(script).ToString();
Console.WriteLine("Array value:" + array[a]);
string rowTypeID = "Entries_" + array[a] + "__TypeID";
select_select_by_index(By.Id("Entries_" + array[a] + "__TypeID"), 1);
IWebElement selectOrg = find_element(By.Name("Entries[" + array[a] + "].OrganisationID_input"));
selectOrg.Clear();
selectOrg.SendKeys("3801 LTD");
IWebElement selectInOffice = driver.FindElement(By.Id("Entries_" + array[a] + "__InOffice"));
selectInOffice.Clear();
selectInOffice.SendKeys("10");
IWebElement selectOffsite = driver.FindElement(By.Id("Entries_" + array[a] + "__Offsite"));
selectOffsite.Clear();
selectOffsite.SendKeys("5");
IWebElement comments = driver.FindElement(By.Id("Entries_" + array[a] + "__Comment"));
comments.Clear();
comments.SendKeys(array[a] + "Manish test");
IWebElement save = find_element(By.XPath("//button[@value='SaveDraft']"));
save.Click();
}
public static void select_select_by_index(By by, int index)
{
var select = new SelectElement(find_element(by));
select.SelectByIndex(index);
}