How to verify page title in Selenium

0 votes
How to verify page title in Selenium?
Jul 4, 2019 in Selenium by Janvi
13,347 views

1 answer to this question.

0 votes

Hey Janvi, you can verify a page's title by using following test script:

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Verify_Page_Title {

    public static void main(String[] args) {

        System.setProperty("webdriver.chrome.driver", "D:\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();

        driver.get("https://edureka.co");
        driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

        String Actual = driver.getTitle();
        String Expected = "Instructor-Led Online Training with 24X7 Lifetime Support | Edureka";

        if (Actual.equals(Expected)) {
                   System.out.println("Test Passed!");
        } else {
                   System.out.println("Test Failed");
        }

        driver.close();
    }
}

For further understanding, you can refer to the Selenium Course.

answered Jul 4, 2019 by Lavanya

Related Questions In Selenium

0 votes
2 answers

How to scroll the Page up or down in Selenium WebDriver? (using java)

JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript("window.scrollBy(0,555)", ""); or Action classes ...READ MORE

answered Sep 6, 2020 in Selenium by Sri
• 3,190 points
18,503 views
0 votes
1 answer

How to replace remote resources with local resource in a page with Selenium?

You could change URL for that script ...READ MORE

answered Aug 8, 2018 in Selenium by Samarpit
• 5,910 points
3,895 views
0 votes
0 answers
0 votes
2 answers

How to verify color of a web element in Selenium Webdriver?

document.getElementsByTagName('div')[0].style.backgroundColor READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
17,009 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
12,742 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,618 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,696 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,557 views
0 votes
1 answer

How to stop test execution in Selenium if an error occured?

Hey Fatima, if you are using any ...READ MORE

answered Jul 4, 2019 in Selenium by Abha
• 28,140 points
10,662 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