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!