How to verify page title in Selenium?

0 votes
How to verify page title in Selenium?
Jul 4, 2019 in Selenium by Janvi
3,661 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();
    }
}
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 5 in Selenium by Sri
• 2,970 points
13,280 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,890 points
312 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 in Selenium by Sri
• 2,970 points
6,976 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,510 points
3,550 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,555 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,890 points
2,608 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 2 in Selenium by Sri
• 2,970 points
2,887 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
• 27,930 points
3,849 views