A very much beginner to JS and coding in general, so my apologies if this is too elementary of a question to ask.
Goal: On a webpage, I am going through a page that has a maximum of five pages total. There is a pagination counter at the bottom that reads "Page x of 5", with the "x" displaying the page the user is on. I simply have to navigate to the "next" page and verify that the pagination text updates to the correct counter text (Page x of 5).
The code is as follows:
let paginationValues = function(){
var nextPageBtn = false
do {
nextBtnPagination = driver.exists('ul.pagination-skipToNext')
if (nextBtnPagination) {
//do stuff
}
} while (nextPageBtn)
The xpath points to a text value with the pagination counter text using Selenium WebDriver.
So basically I have to click the "next page" button if it exists, which I have done. However, I need to validate that the pagination text responds accordingly by making sure the user is navigated to "Page 2 of 5", "Page 3 of 5" and so on.
Please advise.
If all you need is to display the page number that user navigated to, then why don't you just use global variable and increment/decrement its value based on user navigation actions. and display its value, I think this would be much better then trying with selenium webdriver which extract the value through DOM.