import java.util.concurrent.TimeUnit;
import junit.framework.Assert;
import org.junit.Assert.*;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class WebDriverJunit {
public static WebDriver oBrowser;
@BeforeClass
public static void Selenium_init()
{
oBrowser=new FirefoxDriver();
oBrowser.manage().window().maximize();
oBrowser.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS);
oBrowser.get("http://www.bing.com");
}
@AfterClass
public static void Selenium_End()
{
oBrowser.quit();
}
@Test
public void Validate_Edit()
{
WebElement oEdit;
try
{
oEdit=oBrowser.findElement(By.id("sb_form_q"));
Assert.assertEquals("", oEdit.getText());
}
catch(Exception e)
{
Assert.fail(e.getMessage());
}
}
@Test
public void Search()
{
WebElement oEdit,oButton;
String sPageSource;
try
{
oEdit=oBrowser.findElement(By.id("sb_form_q"));
oButton=oBrowser.findElement(By.id("sb_form_go"));
oEdit.sendKeys("Selenium");
oButton.click();
sPageSource=oBrowser.getPageSource();
oBrowser.navigate().back();
if (sPageSource.lastIndexOf("Selenium")<100)
{
Assert.fail("No Proper result");
}
}
catch(Exception e)
{
Assert.fail(e.getMessage());
}
}
}
same thing works with TestNG
ReplyDeleteExcellent Post. Also visit http://whiteboxqa.com/selenium.php
ReplyDeleteHi
ReplyDeleteI read this post two times.
I like it so much, please try to keep posting.
Let me introduce other material that may be good for our community.
Microsoft dynamics training
Hi
ReplyDeleteI read this post two times.
I like it so much, please try to keep posting.
Let me introduce other material that may be good for our community.
Microsoft dynamics training
Nice Post! Also visit http://arvindkj.blogspot.in/
ReplyDeleteExcellent Post.Also visit http://www.whiteboxqa.com/WBQA/google/selenium-webdriver-and-junit-class-design.php
ReplyDeleteIt was very nice article and it is very useful to Selenium learners.We also provide Cub training software online training.
ReplyDeleteThanks you for the awesome information in your blog on Selenium training in Chennai
ReplyDeleteValuable information thanks for sharing HP ALM Online Training BY Cheyat Technologies
ReplyDeleteThanks you for the awesome information in your blog.
ReplyDeleteselenium training in chennai
Thanks for your valuable post.
ReplyDeleteibm-message-broker training in chennai
Valuable information thanks for sharing..
ReplyDeleteoracle training in chennai
• Thanks for all your information, Website is very nice and informative content.
ReplyDeletemsbi training in chennai
Excellent Post!!WebSphere Training in Chennai
ReplyDeleteThe Best Amazon Web-services in Chennai! Amazon Web-services in Chennai
ReplyDelete
ReplyDeleteAdvanced Selenium Framework Training in Chennai by Vishwa
Hi, Reach Mr.Vishwa for Best Selenium and Coded UI Training in Chennai with real time project assistance. This people will teach everything from the basics up to advanced level scenarios from frameworks.
I learned from Mr.Vishwa and Raj they are very good automation people for Selenium Frameworks. After joined with them I learned many things and now I am writing automation scripts in own project. Vishwa 9003085882
selenium training in chennai
This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
ReplyDeleteSelenium Training in Chennai
Excellent post. I would like to tell about Supreet. Supreet Solutions is the Best Institute For Advanced Selenium Classroom And Online Training Institute In Hyderabad By 15+ years of Real Time Industry experts.
ReplyDeleteBest Selenium Training Institute In Hyderabad | Online Selenium Training
Hi Shiva....interested in some technical discussion asap..can you ping me on this email:sshree43@gmail.com
ReplyDeleteLearned a lot from your post and it is really good. Share more tech updates regularly.
ReplyDeleteAWS Training in Chennai
AWS course in Chennai
DevOps certification in Chennai
DevOps Training in Chennai
Data Science Course in Chennai
Data Science Training in Chennai
AWS Training in OMR
AWS Training in Porur
Amazing blog. It's very helpful to learn these things easily. Thank You so much. Keep supporting.
ReplyDeleteaws training in chennai | aws course in chennai