/* * Enter text in the textbox */ void IActionsVisitor.visitTextBox(ArcliteTextBox element, InputVal wanted) { string text = wanted.getSelectedVal(); IWebElement input; long number = 0; bool canConvert = long.TryParse(text, out number); if (element._secondXPath == null) { try { input = wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath(element.elementXPath))); new ArcliteButton("", element.elementXPath).accept(this, new InputVal()); } catch (WebDriverTimeoutException) { input = driver.FindElement(By.XPath(element.elementXPath)); } } else { input = wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath(element.elementXPath + wanted.valTwo + element._secondXPath))); new ArcliteButton("", element.elementXPath + wanted.valTwo + element._secondXPath).accept(this, new InputVal()); } if (canConvert) { input.Clear(); input.SendKeys(text); } else { driver.ExecuteJavaScript("arguments[0].value = '" + text + "';", input); } }
private void checkEntryFromTable(ArcliteDataTable element, InputVal wanted) { string text = wanted.getSelectedVal(); IArcliteWebElement search = element._searchElement; search.accept(this, wanted); if (element._confirmDelete == null && element._cancelDelete == null) { IArcliteWebElement check = new ArcliteButton("", element._tableEntryFirst + text + element._tableEntrySecond); check.accept(this, new InputVal()); } else if (element._expand == null) { IArcliteWebElement delete = new ArcliteButton("", element._tableEntryFirst + text + element._tableEntrySecond); delete.accept(this, new InputVal()); } else if (element._expand != null) { IArcliteWebElement expand = new ArcliteButton("", element._tableEntryFirst + wanted.valTwo + element._tableEntrySecond + element._expand); expand.accept(this, new InputVal()); } else { throw new ArgumentException("something is or is not null"); } }
/* * selects from a dropdown with wanted option */ void IActionsVisitor.visitSelect(ArcliteSelect element, InputVal wanted) { string text = wanted.getSelectedVal(); IArcliteWebElement dropdown = new ArcliteButton(element.elementName, element._dropDownXpath); dropdown.accept(this, new InputVal()); Thread.Sleep(shortSleepTime); SelectElement selectElement = new SelectElement(driver.FindElement(By.XPath(element._selectXPath))); if (element._optionFirst == null) { //get the options as a select element selectElement.SelectByText(text); } else { string dataVal = Util.getDataValue(text, selectElement); IArcliteWebElement selectOption = new ArcliteButton("", element._optionFirst + dataVal + element._optionSecond); selectOption.accept(this, new InputVal()); } }