Solutions To PracticeQa Examples
Saturday, 8 August 2015
PracticeQASolutions - TextBoxes
TestData:
UserName: User1
Email: PracticeQA
Solution:
Java:
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.Test; public class TextBoxes { private static String url = "http://practiceqa.blogspot.in/2015/08/automation-scenario-example-textboxes.html"; private static String containerUserNameBlank = "//input[@name='UserName']"; private static String containerEmailIdBlank = "//input[@name='EmailId']"; private static String containerUserNameWithData = "//input[@name='UserNameWithText']"; private static String containerEmailIdWithData = "//input[@name='EmailIdWithText']"; private static String UserName="PracticeQAUserName"; private static String EmailId="PracticeQAEmailId"; @Test public void testTextBoxes(){ WebDriver driver = new FirefoxDriver(); driver.manage().window().maximize(); driver.get(url); //To Enter Data Into Blank Textboxes: driver.findElement(By.xpath(containerUserNameBlank)).sendKeys(UserName); driver.findElement(By.xpath(containerEmailIdBlank)).sendKeys(EmailId); //To Enter Data Into Textboxes with initial data: WebElement userName= driver.findElement(By.xpath(containerUserNameWithData)); userName.clear(); userName.sendKeys(UserName); WebElement email= driver.findElement(By.xpath(containerEmailIdWithData)); email.clear(); email.sendKeys(EmailId); } }
PracticeQASolutions - Hello Page
Hello Everyone,
In this blog you can find solutions to the examples given in
PracticeQA
blog. Hope these will help you in learning automation. Please visit
PracticeQAEnvironmentSetup
Page to learn how to run the solutions provided in this blog. Happy Learning.
Regards,
PracticeQASolutions
Newer Posts
Home
Subscribe to:
Posts (Atom)