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, 2020 in Selenium by anonymous
• 410 points
1,019 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, 2020 in Selenium by Jordan
• 410 points
778 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
• 28,140 points
1,044 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, 2020 in Selenium by Karan
• 19,610 points
8,340 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, 2020 in Selenium by Sri
• 3,190 points
2,890 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
13,673 views
0 votes
1 answer

Diff between WebDriver listeners and TestNG listeners?

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

answered Apr 14, 2018 in Selenium by king_kenny
• 3,710 points
6,468 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,142 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