Привет.
Я подумал что первую задачку можно решить так(C#):
//Метод для определения существования элемента public static bool IsElementPresent(IWebDriver driver, By by) { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5)); try { wait.Until(ExpectedConditions.ElementExists(by)); wait.IgnoreExceptionTypes(typeof(NoSuchElementException)); return true; } catch (Exception) { return false; } } //-------------------------Тестируемый кусок------------------------- string expCountryName = "Russia"; string expDocName = "Doc"; //Проверка существования строки с именем expCountryName By countryTr = By.XPath(string.Format("//tr[td[contains(text, '{0}')]]", expCountryName)); By docTd = By.XPath(string.Format("//tr[td[contains(text, '{0}')]]/td[2][contains(text(), {1})]", expCountryName, expDocName)); //Если элемент существует, проверить существование документа if(IsElementPresent(driver, countryTr)) { if(IsElementPresent(driver, docTd)) throw new Exception("DocName "+ expDocName +" tr does not exist"); } else throw new Exception("CountryName "+ expCountryName +" tr does not exist");
Вторую задачку я не понял так что не взялся за нее (С состояниями).