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,100 points
748 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,460 points

Related Questions In Selenium

0 votes
0 answers

Getting Java Null Pointer Exception on running the test case in Seleniumn.Can someone pls let me know where i need to fix in order to progress

Below is the Error: java.lang.RuntimeException: java.lang.NullPointerException at org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:49) at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:131) at ...READ MORE

Sep 11, 2020 in Selenium by sandhya
• 180 points
12,655 views
0 votes
1 answer

How to disable a test case in testNG?

You can use the enable method to ...READ MORE

answered Jan 3, 2019 in Selenium by Nabarupa
2,150 views
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 13, 2019 in Selenium by Anvi
• 14,150 points
1,472 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 14, 2019 in Selenium by Pratibha
• 3,690 points
2,841 views
0 votes
2 answers

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,500 points
13,674 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,143 views
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,910 points
7,221 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,874 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,460 points
13,860 views
+10 votes
17 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,360 points
197,976 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP