Executing Test Case in Java

0 votes
I want to know how to execute Selenium using Java. If any one can provide me with an example it would be great.
Apr 27, 2018 in Selenium by Perry
• 17,020 points
39 views

1 answer to this question.

0 votes
Below is a code for Facebook login which will help you to understand Selenium test cases in a better way:

package FacebookDemos;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

public class FacebookLogin {

public static void main(String[] args) {

// TODO Auto-generated method stub

FacebookLogin obj = new FacebookLogin();

obj.loginBrowser();

}

public void loginBrowser() {

System.setProperty("webdriver.firefox.marionette","D:\\geckodriver.exe");

WebDriver driver = new FirefoxDriver();

driver.manage().window().maximize();

driver.manage().deleteAllCookies();

driver.manage().timeouts().pageLoadTimeout(15,TimeUnit.SECONDS);

driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);

driver.get("http://www.facebook.com");

driver.findElement(By.name("email")).sendKeys("your Email address");

driver.findElement(By.name("pass")).sendKeys("password");

driver.findElement(By.id("loginbutton")).click();

}

}
answered Apr 27, 2018 by Meci Matt
• 9,420 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

How can I create a POM test case in Selenium Webdriver?

Hey Akshay, follow these steps to create ...READ MORE

answered May 12 in Selenium by Anvi
• 12,860 points
53 views
0 votes
1 answer

How to write a test case in Selenium IDE?

Hey Sam, to write a test case ...READ MORE

answered May 13 in Selenium by Pratibha
• 2,780 points
29 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,090 points
582 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
898 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
571 views
0 votes
1 answer

Login page test script using selenium and java in Eclipse IDE

Here is an example to login to ...READ MORE

answered Apr 23, 2018 in Selenium by Meci Matt
• 9,420 points
2,674 views
+9 votes
14 answers

How to automate gmail login process using selenium webdriver in java?

Check the below code: Here is the working ...READ MORE

answered Apr 24, 2018 in Selenium by Vardy
• 2,250 points
59,549 views