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 in Selenium by Kanak
64 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 by Anvi
• 13,400 points

Related Questions In Selenium

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
604 views
0 votes
1 answer
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
762 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
1,004 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
716 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 12 in Selenium by Anvi
• 13,400 points
64 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 in Selenium by Anvi
• 13,400 points
124 views