Example for Selenium WebDriver

0 votes
I am totally new to selenium and want to have an example to execute Selenium. I have installed JDK, Selenium JARs and Eclipse IDE. I want to have a small program to understand the format....
Apr 27, 2018 in Selenium by Perry
• 17,100 points
356 views

1 answer to this question.

0 votes
Here is a small program to login to Facebook, I hope it will help you out to understand the format in which we write Selenium test scripts:

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
1 answer

Using gettext() method for the specific element using Selenium WebDriver

Mistake is that u r printing the ...READ MORE

answered Apr 10, 2018 in Selenium by Vardy
• 2,360 points
28,449 views
0 votes
2 answers

Latest Version of Chrome Driver for Selenium Webdriver

Hi, you can get the latest version ...READ MORE

answered Aug 28, 2019 in Selenium by Abha
• 28,140 points
5,155 views
0 votes
1 answer

What is the default profile for Selenium WebDriver?

While using Firefox in Selenium WebDriver 3.0, ...READ MORE

answered May 14, 2018 in Selenium by Meci Matt
• 9,460 points
3,545 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
12,711 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
8,608 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
6,680 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,551 views
0 votes
1 answer

XPath for the elements with no ID or Name in Selenium Webdriver

Use like this or similar to this: //div[@id="top-level-menu-item-3"]/div[@class="filter-label"] //div[@id="top-level-menu1"] ...READ MORE

answered Apr 17, 2018 in Selenium by Meci Matt
• 9,460 points
6,877 views
0 votes
1 answer

Performing authentication for FirefoxDriver, ChromeDriver and IEDriver using Selenium WebDriver

Use the below code for firefox: profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", "google.com"); driver ...READ MORE

answered May 9, 2018 in Selenium by Meci Matt
• 9,460 points
2,368 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