i want to automate below secaniro using testng and pom but using below code i am only able to open facebook directlt but what i want to do is i wantto open chrome and then navigate to facebook

+1 vote

Open a Chrome browser.
Navigate to “http://www.facebook.com,"
Verify that the page is redirected to “http://www.facebook.com, by getting the current URL. (use if-else condition to verify this condition or use Assert.assertequals() in case you are familiar with TestNG or JUnit)
Verify that there is a “Create an account” section on the page.

package facebook;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

import org.testng.annotations.Test;

import POM.PomDemo;

public class facebooktest {

@Test

public static void PomDemo()

{

System.setProperty("webdriver.chrome.driver","D:\\selenium\\chromedriver.exe");

WebDriver driver = new ChromeDriver();

driver.get("https://www.facebook.com/");

PomDemo.textbox(driver);

------------------------------------------------

package facebook;

import org.openqa.selenium.By;

import org.openqa.selenium.Keys;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

public class Facebooklogin {

public static WebElement textbox(WebDriver driver) {

WebElement search=driver.findElement(By.name("q"));

search.sendKeys("Google");

search.sendKeys(Keys.ENTER);

return search;

}

public static WebElement searchbutton(WebDriver driver){

search=driver.findElement(By.name("btnk"));

return search;

}

}
Sep 23 in Selenium by anonymous
• 410 points
132 views
That is probably because your code directly has a Facebook URL instead of first opening chrome.

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Selenium

+1 vote
0 answers

Hello i have written below code to verify title using POM method but i am not able to print please help me

public static void verifytitle() { String Createanewaccounttttt=driver.getTitle(); System.out.println("Title is"+Createanewaccounttttt); String excepted_title="Create ...READ MORE

Sep 24 in Selenium by Jordan
• 410 points
58 views
0 votes
2 answers

I am trying to run the below code but java.lang.Illegalstate Exception is coming

You are facing this error because while ...READ MORE

answered Jun 21, 2019 in Selenium by Abha
• 27,930 points
258 views
+1 vote
1 answer

How can I automate the process of adding iPhone to cart in Flipkart using Selenium(java),Page Object Model and TestNG? Also validate if product is added and available in cart?

Hey check this https://www.edureka.co/community/47160/automate-purchase-adding-book-cart-flipkart-using-selenium? It deals with a similar ...READ MORE

answered Jan 13 in Selenium by Karan
• 18,400 points
2,715 views
0 votes
1 answer
0 votes
2 answers

What is the role of TestNG & JUnit frameworks in Selenium?

TestNG and JUnit are test frameworks . it ...READ MORE

answered Sep 4 in Selenium by Sri
• 2,970 points
881 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,520 points
3,752 views
0 votes
1 answer

Diff between WebDriver listeners and TestNG listeners?

This is not a very important concept ...READ MORE

answered Apr 13, 2018 in Selenium by king_kenny
• 3,710 points
2,517 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

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

answered Aug 31 in Selenium by Sri
• 2,970 points
4,736 views