I have the written the following test case:
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System.Threading;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Chrome;
namespace Test1
{
[TestClass]
public class BS1T1FailCasePage3
{
[TestMethod]
public void TestMethod1()
{
var driver = new ChromeDriver(@"E:\Series\Drivers");
driver.Navigate().GoToUrl("http://ift.tt/2dhQ3cI");
var xpathElement = driver.FindElement(By.XPath(".//*[@id='SSN']"));
xpathElement.SendKeys("1234");
var xpathElement1 = driver.FindElement(By.XPath("//option[contains(text(),'January')]"));
xpathElement1.Click();
var xpathElement10 = driver.FindElement(By.XPath("//option[text()='1']"));
xpathElement10.Click();
driver.FindElement(By.XPath(".//*[@id='Terms']/div[3]/section/label[1]/i")).Click(); //Checkbox1
driver.FindElement(By.XPath(".//*[@id='Terms']/div[3]/section/label[2]/i")).Click(); //Checkbox2
driver.FindElement(By.XPath(".//*[@id='Terms']/div[3]/section/label[3]/i")).Click(); //Checkbox3
driver.FindElement(By.XPath(".//*[@id='frmGatekeeper']/fieldset[4]/div/div[1]/button")).Click(); //Button to next page
driver.FindElement(By.XPath("//option[@value='Refinance[SB1]']")).Click(); //Dropdown option 1
//driver.FindElement(By.XPath("//option[@value='Purchase']")).Click(); //Dropdown option 2
driver.FindElement(By.XPath(".//*[@id='frmQuestionnaire']/fieldset[2]/section[1]/div/div[2]/div/div[1]/label[2]/i")).Click(); //Radio button option = Yes
//driver.FindElement(By.XPath(".//*[@id='frmQuestionnaire']/fieldset[3]/section[1]/div/div[2]/div/div[1]/label[2]/i")).Click(); //Radio button option = No
driver.FindElement(By.XPath(".//*[@id='Question03_SubQuestions']/div[1]/div[2]/div/div[1]/label/i")).Click();
driver.FindElement(By.XPath(".//*[@id='frmQuestionnaire']/button")).Click();
var loggedInHeader = driver.FindElement(By.XPath(".//*[@id='heading']"));
String p = "Initial Borrower Survey";
if (loggedInHeader.Text.Contains(p))
{
Assert.IsTrue(loggedInHeader.Displayed, "Test Passed.");
}
else
{
Assert.IsFalse(loggedInHeader.Displayed, "Test Failed.");
}
}
}
}
Basically it's a general case where I designed scenario to test a phenomenon on my web application. As you can see from the code the page has textboxes, checkboxes, radio buttons and drop downs. So everytime I run my case I comment out some options and see if the responses are proper. I just wanted to know if it's possible for to write a piece where I can run each permutation and combination of radio button options or drop down options at random without commenting it out every time or doing it manually. Also rather than comparing the page outcome at the end, is it possible to record what is being showed as a result of these selections.
Kindly let me know.
Aucun commentaire:
Enregistrer un commentaire