Back and forward buttons, capture page title using Selenide

Tutorial 5​​ ​​ Buttons simulation (Back, forward), page title, page refresh​​ using​​ Selenide

What you will Learn:

  • Print page title

  • Navigate to another url

  • Navigate back

  • Navigate forward

  • Refresh page

  • Code snippet

Print page title

We can print the page title by simply using the ‘title()’ method​​ 


Navigate to another url

Next, let us navigate to a different url and print the page title

Notice below that 2nd​​ url is launched in the same browser tab window and the title gets printed

 

Navigate back

To navigate back, we can simply use ‘back()’ method

 

Navigate forward

To navigate forward

 

Refresh page

For page refresh,​​ we have refresh() method

Notice the o/p, the last 2 titles are same

Code snippet

package​​ w2a.selenide;

 

import​​ org.openqa.selenium.By;

import​​ org.testng.Assert;

import​​ org.testng.annotations.Test;

import​​ com.codeborne.selenide.CollectionCondition;

import​​ com.codeborne.selenide.Condition;

import​​ com.codeborne.selenide.Configuration;

import​​ static​​ com.codeborne.selenide.Selenide.*;

import​​ static​​ com.codeborne.selenide.Condition.*;

 

public​​ class​​ FirstSelenideTest {

@Test

public​​ void​​ searchTest()​​ throws​​ InterruptedException {

open("https://www.way2automation.com/");

 System.out.println(title());

open("https://www.facebook.com/way2automation");

 System.out.println(title());

 Thread.sleep(2000);

back();

 System.out.println("After navigating back -->"​​ +​​ title());

forward();

 System.out.println("After navigating forward -->"​​ +​​ title());

refresh();

 System.out.println("After page refresh -->"​​ +​​ title());

 }

}


Thank you for reading!

Share On

Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp
Share on tumblr
Share on email

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

Lifetime Membership Club

LIFETIME MEMBERSHIP BIG SALE - ALL LIVE COURES JUST - 7000 RS/ 99 USD
Attend All Live courses in just 7000 rs / $99 - offer ends 31st DEC 2024