Я пишу простой тест на селен, который отправляет неверную строку букв, затем отправляет и возвращает и ошибка. Затем я хочу отправить строку письма, но на этот раз с правильной строкой, чтобы она была принята.
Проблема, с которой я сталкиваюсь в своем тесте, заключается в том, что первый набор строк уже находится в текстовом поле, поэтому, когда я перехожу к отправке второго, он добавляет его к первой уже отправленной строке.
Итак, что мне по существу нужно сделать, это отправить первую строку букв, затем очистить текстовое поле, а затем отправить вторую строку букв.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Interactions;
using System.Threading;
namespace Exercise1
{
class RunPath
{
static void Main()
{
IWebDriver webDriver = new ChromeDriver();
webDriver.Navigate().GoToUrl("https://energy.gocompare.com/gas-electricity");
webDriver.Manage().Window.Maximize();
String title = webDriver.Title;
String expectedTitle = "Utilities from Go Compare";
if (title.Contains(expectedTitle))
{
Console.WriteLine("Tile is matching with expected value");
}
else
{
Console.WriteLine("Tile is matching with expected value");
}
webDriver.FindElement(By.XPath(".//button[@type = 'submit']")).Click();
webDriver.FindElement(By.XPath(".//input[@type = 'text']")).SendKeys("W30PN#");
webDriver.FindElement(By.XPath(".//button[@type = 'submit']")).Click();
// I need a piece of code here so that before i send the second string of keys the text field is clear
webDriver.FindElement(By.XPath(".//input[@type = 'text']")).SendKeys("W30PN");
webDriver.FindElement(By.XPath(".//button[@type = 'submit']")).Click();
// webDriver.Quit();
}
}
}