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

Applying CSS to an iframe using JavaScript: A Step-by-Step

I have an Iframe editor and I am trying to change some CSS inside the editor. However, when I attempt to apply the CSS, it does not affect the styles within the Iframe. <div id="editor" style="flex: 1 1 0%;"> <iframe src="https://editor.unlay ...

The specified action to begin the app is either missing or unable to be initiated in Appium

I am encountering an issue when trying to launch the app on my mobile device using the following code: package Mobileapp1; . . import io.appium.java_client.remote.MobileCapabilityType; public class Apptesting { public static void main(String[] args) ...

Selenium WebDriver encountering TimeoutException when calling getScreenshotAs()方法

This is the code I am working on. public static void executeTest() throws IOException { System.setProperty("webdriver.chrome.driver", "data/chromedriver.exe"); driver = new ChromeDriver(); driver.manage().timeouts().pageLoadTimeout(30, TimeUni ...

Position the center button evenly between two images, aligned vertically using percentages

I'm attempting to achieve a specific layout that includes images scaling across Bootstrap breakpoints and a static button position. The challenge is maintaining the layout as depicted in the mockup, regardless of image size. The images are set to im ...

Is there a way to choose an item from a dropdown menu in Selenium using Python if the option's element is not clickable?

I am encountering an issue while trying to select an item from the dropdown menu. The options that I need to choose from are not selectable and display an alert message stating, "Alert: This element is not interactable through selenium(automation) as it is ...

How to click on a hyperlink element without any attributes in Selenium using Python

Hey there, I'm facing a challenge where I need to click on a href link that doesn't have any class, id, text, or anything at all. <div> <a href="/ad/repost/id/2109701"> <span>Réafficher</span> <i clas ...

Incorporating fresh data from a node.js backend to refresh a webpage section

I'm currently working on creating an app that can retrieve the song a user is currently listening to using a web scraper. While I've managed to direct users to the page and display the current song title, they must manually refresh the entire pag ...

Using CSS box-shadow to elevate an image

I am looking to create a background wrapper using CSS instead of an image. My goal is to add box shadow to achieve the same look as shown in the attached image. I understand that I will need to use the box-shadow property for this task. However, I am uns ...

After a link is clicked in the Rails web app, the style undergoes a subtle transformation

Encountering an issue with my HTML/CSS that seems to be connected to Rails and its asset pipeline. Initially, the styling of my web app is perfect on the first page load (and hard refreshes). However, as soon as I click on a link, navigate away from the pa ...

Utilizing Robot Framework's powerful ability to combine various mixins for enhanced functionality

I am currently working on a project that involves robot framework, the pageobject library, and selenium2library. Unfortunately, I have been unable to figure out how to use multiple mixins on a single page object. I am trying to utilize two mixins with ...

Navigating through the website - Attempting to select the Advanced Search Tab does not seem to expand the tab fully

While I am exploring this particular website, , I encountered an issue when trying to enter the name of a specific factory into the 'Factory' search box within the Advanced Search section. I have observed that if I do not manually select the tex ...

The HR element seems to be fixed in place and is not moving

I'm having trouble figuring out what's causing the issue, so I wasn't sure how to title it. Any help in looking at the code would be greatly appreciated. Here is the problem: The HR tag should be positioned below the last image and not cut ...

Enhancing your declared variables in Robot Framework by adding new variables

Is there a way to incorporate variables into declared variables in robot framework? I currently have multiple table variables within my script. Here is an example: *** Variable *** ${Amount1_Column} xpath=//div[@id='*GFtable***0***EventDealDataValida ...

What is the best way to insert horizontal padding into each line of a single sentence that is wrapped on multiple lines

Below is the code snippet I am working with: <div><p><span>... highlighted text ...</span></p><p>Chapter info</p></div> Here is a screenshot of how it currently appears: I am looking for a way to add paddi ...

Alternating row colors using CSS zebra striping after parsing XML with jQuery

After successfully parsing XML data into a table, I encountered an issue with applying zebra stripe styling to the additional rows created through jQuery. Despite my efforts to troubleshoot the problem in my code, I remain perplexed. Below is a snippet of ...

What is the most effective way to create a live preview using AngularJS and CSS?

Is there a way to dynamically change the background color of the body based on the hexadecimal value entered in a textfield, without using jQuery? I want the change to happen live as the user types. The current code works but it doesn't feel right. I ...

Tips on adjusting the width of a div container based on the size of an

I am struggling with setting the width of my "picBox" div equal to the image tag inside. I have tried adjusting the CSS code but cannot seem to get it right. Any suggestions on how to solve this issue would be greatly appreciated. Thank you. The CSS code: ...

Streamlining tinymce functionality through selenium automation

I'm encountering difficulties when trying to write on tinymce version 3.5.8. def self.content(text) # In order to write on a WYSIWYG editor, you need to write on the iframe $driver.switch_to.frame('WikiRevision_content_ifr') $driver.f ...

Ways to display or conceal multiple div elements using JavaScript

A group of colleagues and I are currently collaborating on a project to create a website showcasing our research. We have incorporated 1 page that contains detailed descriptions of six different subjects: system biology, proteomics, genomics, transcripto ...

What causes a new stacking context to be formed when using position: relative without z-index?

After reading this informative piece: When two elements share the same stack level, their layering is determined by their order in the source code. Elements stacked successively are placed on top of those that came before them. And referencing this ar ...