The XPath for pagination is incorrect

Whenever I try to navigate to the next page, I keep encountering an error from the robot.

Can someone help me construct the xpath using either of these snippets:

<li title="2" class="ant-pagination-item ant-pagination-item-2" tabindex="0">
or
<li title="Next Page" class="ant-pagination-next"

This is the script:

*** Settings ***
Library    Browser
Library    OperatingSystem
Resource   ../Resources/BrowserParameters.robot
Resource   ../Resources/BrowserResources.robot
Resource   ../Resources/BrowserCustomKeywords.robot

#Select Browser: chromium or firefox
Test Setup      Test Setup    Browser=chromium
Test Teardown   Test Teardown

*** Test Cases ***
001-01-Upload13Videos-Delete2Videos-Upload2Videos-Process
    Click     ${Page-Inference}
    Upload Multiple Video Files
    Click    //title[@class="ant-pagination-item ant-pagination-item-2"])

Check out the outer HTML:

<ul class="ant-pagination mini ant-table-pagination ant-table-pagination-right" unselectable="unselectable">
    <li title="Previous Page" class="ant-pagination-prev ant-pagination-disabled" aria-disabled="true">
        <button class="ant-pagination-item-link" type="button" tabindex="-1" disabled="">
            <span role="img" aria-label="left" class="anticon anticon-left">
                <svg viewBox="64 64 896 896" focusable="false" data-icon="left" width="1em" height="1em" fill="currentColor" aria-hidden="true">
                    <path d="M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"/>
                </svg>
            </span>
        </button>
    </li>
    <li title="1" class="ant-pagination-item ant-pagination-item-1 ant-pagination-item-active" tabindex="0">
        <a rel="nofollow">1</a>
    </li>
    <li title="2" class="ant-pagination-item ant-pagination-item-2" tabindex="0">
        <a rel="nofollow">2</a>
    </li>
    <li title="Next Page" class="ant-pagination-next" aria-disabled="false" tabindex="0">
        <button class="ant-pagination-item-link" type="button" tabindex="-1">
            <span role="img" aria-label="right" class="anticon anticon-right">
                <svg viewBox="64 64 896 896" focusable="false" data-icon="right" width="1em" height="1em" fill="currentColor" aria-hidden="true">
                    <path d="M765.7 486.8L314.9 134.7A7.97 7.97 0 00302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 000-50.4z"/>

Here's the error message:

Error: locator.click: DOMException: Failed to execute 'evaluate' on 'Document': The string './/title[@class="ant-pagination-item ant-pagination-item-2"])' is not a valid XPath expression.
=========================== logs ===========================
waiting for selector "//title[@class="ant-pagination-item ant-pagination-item-2"]) >> nth=0"
  Failed to execute 'evaluate' on 'Document': The string './/title[@class="ant-pagination-item ant-pagination-item-2"])' is not a valid XPath expression.
============================================================

Answer №1

You have utilized the xpath

//title[@class="ant-pagination-item ant-pagination-item-2"])

Your current xPath expression is incorrect because xPath expressions should be structured like this

//tagName[@attributeName='attributeValue']

Therefore, your xpath should be

//li[@class='ant-pagination-item ant-pagination-item-2']

Alternatively, you can use this xpath if you are specifically targeting pagination and adding an index wouldn't hurt [See below]

//li[@title='2']

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for preventing HTML ID clashes while integrating with the Document Object Model of external websites

When incorporating additional HTML elements into a webpage using Javascript or jQuery, along with external CSS declarations, it is important to avoid conflicts with existing IDs and class names already present on the page. This could lead to issues if ther ...

What is the best way to reduce the size of an image using a URL?

As I work on creating a website in React for a company, my main focus is on developing a drive repository where users can upload files. One issue that has arisen is the performance of the "photos" folder, as it contains numerous high-resolution images th ...

Creating a scrollable panel using CSS is easy with a solid border and a panel element

Using Vaadin to design my front-end, I encountered an issue where adding border-style:solid to the style.css file resulted in a scrollable v-panel. How can I retain the solid style while removing the scrolling feature? Please refer to the screenshot for cl ...

Choose an XML filter using a dropdown menu

Is there a way to extract the "B3" String from an XML tree for use in Selenium? I would really appreciate any assistance on this. :) Thank you so much in advance! https://i.stack.imgur.com/HIIZR.png ...

What could be the reason for the sudden malfunction of the .tabs li:hover property on my

I'm having trouble with the :hover effect not working on my .tabs li element. I've tried commenting out my jQuery script, but it still won't apply. Can anyone help me figure out why? Here's a JSFiddle link for reference: https://jsfidd ...

Troubleshooting Vue.js rendering problems on Safari_BROWSER

I'm encountering a strange issue with my portfolio website, which is built using Vue and Laravel. The problem arises specifically in Safari - the project thumbnails don't display until the browser window is resized. Here's the relevant code ...

Is selecting an element in Chrome causing problems during selenium automation?

driver.findElement(By.xpath("//button")).click(); anticipated outcome: Button successfully clicked. current outcome: Error caused by: org.openqa.selenium.ElementNotVisibleException: Element must be displayed to click (WARNING: The server did not provide ...

Adding clickable padding to a Draft.js editor can enhance the user experience and make the editing process

Is there a way to apply padding to the Draft.js Editor so that clicking on the padding area selects the Editor? If I add padding directly to the container div of the Editor, the padding displays properly but clicking on it does not enable writing in the E ...

jquery is in motion while svg paths are at a standstill, waiting to

i have been attempting to incorporate a css-animated svg into my project. initially, the animation would start automatically, which was undesirable. after some research, i discovered that by declaring it as paused and then triggering it using jQuery with $ ...

Guide to adding content and icons to the top navbar on the right side using vue.js

In the process of developing a fixed top navbar, I encountered an issue while trying to add right side icons and additional content. The goal is to include two icons, as shown in this example: example link, along with profile and cart information on the ri ...

The horizontal navigation bar will not extend the entire length of the page

I'm facing an issue with my horizontal navigation bar as it doesn't span the entire screen. I need help figuring out how to make it full-width. You can see what I mean here. Additionally, once the navigation bar spans the screen, I want the image ...

How can I use touch events in Python with Webdriver?

I have searched extensively for touch event examples using the Java webdriver, but surprisingly I could not find any for Python. Could someone please share a Python example here to save others from wasting hours looking for it? Below is my attempt at perfo ...

Having trouble clicking on an element with Selenium? It might be either "not clickable" or "not found."

Struggling to click on the "Sign In" button on www.tradingview.com. I've utilized an implicitly_wait and attempted to locate the element by xPath and class name. Unfortunately, all my efforts result in either element not interactable or unable to loca ...

various image proportions in HTML

I have an image with a ratio of 16:9 that I want to use on my website. On one of the pages, I display a list of products with images having a ratio of 340x265. When a user clicks on an item in the list, it takes them to the product page where the same im ...

How to Add Elements to a List Using Nightwatch.js

I have been using the findElements function in Java like this: public static List<WebElement> listIGP (WebDriver driver) throws Exception { elementList = driver.findElements(By.xpath(".//*[starts-with(@id,'bg_widget_Asset_')]"))); ...

Navigating back to the current page from a frame using Selenium Webdriver

What is the best method for returning to the main page from an iframe? For example: driver.SwitchTo.Frame(1); driver.SwitchTo().DefaultContent(); The above code snippet is not working. Does anyone have any alternative solutions to regain control? ...

Positioning Tool Tips with Material Design Lite

While utilizing MDL tooltips (), the tooltip typically displays just below the <div> it is linked to. I am aiming for the tooltip to show up to the right of the referenced element, rather than beneath it. My attempt to adjust the appearance in styl ...

Getting rid of the Horizontal Scroll Bar

Having trouble with a persistent horizontal scrollbar in the "section3__container" container despite attempts to adjust size and overflow settings. Need assistance in removing this unwanted feature. <html lang="en"> <head> <m ...

Design an HTML button/label with text and a starting width of zero

I'm attempting to design HTML buttons and labels with text that initially have zero width. Once inserted, they should smoothly transition to a visible state. I've tried adjusting the initial width and min-width style properties without success. ...

Expansive dropdown menu stretching across the entire width, yet the content within restricted to a width of

I have recently made some updates to our website's dropdown menu, expanding the results displayed. However, I would like the dropdown contents to fit within the width of our page. I have tried adjusting the CSS with limited success: .menu > ul > ...