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

How to Create Object Repository in Selenium Web Driver?

Try POM Model (Page object model). Refer ...READ MORE

answered Apr 17, 2018 in Selenium by adam
1,696 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
12,714 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,682 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

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,219 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,062 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