How to create an Object Repository to test facebook login in Selenium Webdriver

0 votes
How to create an Object Repository to test facebook login in Selenium Webdriver?
Jul 17, 2019 in Selenium by Kanak
2,231 views

1 answer to this question.

0 votes

Hi Kanak, to test facebook login using an Object Repository, you can use this code snippet:

<span style="font-size: 14pt; font-family: arial, helvetica, sans-serif;">import java.io.File;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class TestFacebookLogin {

@Test
public void TestOR() throws IOException{

File src=new File(".Object_Repo.properties");
FileInputStream fis=new FileInputStream(src);

// Create Properties class object to read properties file
Properties properties =new Properties();

// Load file so we can use into our script
properties.load(fis);

System.out.println("Property class loaded");

WebDriver driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://www.facebook.com");

driver.findElement(By.xpath(pro.getProperty("facebook.login.username.xpath"))).
sendKeys("anvi.rajawat@gmail.com");

driver.findElement(By.xpath(pro.getProperty("facebook.login.password.xpath"))).
sendKeys("password");

driver.findElement(By.xpath(pro.getProperty("facebook.login.Signup.xpath"))).click();

}
}

</span>
answered Jul 17, 2019 by Anvi
• 14,150 points

Related Questions In Selenium

0 votes
1 answer
0 votes
0 answers

How to Create Object Repository in Selenium Web Driver?

I wanted to know how to create ...READ MORE

Apr 17, 2018 in Selenium by Shubham
• 13,490 points
1,975 views
0 votes
1 answer
0 votes
2 answers
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,724 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,166 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,242 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,885 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,479 views
0 votes
1 answer

How to create a Base Class in Selenium and use it with test scripts?

Hi Donna, you can use following code ...READ MORE

answered Jul 18, 2019 in Selenium by Anvi
• 14,150 points
12,632 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