Questions tagged [xpath]

XPath (XML Path Language) is language for addressing parts of an XML document, designed to be used by both XSLT and XPointer. It also provides basic facilities for manipulation of strings, numbers and booleans. XPath uses a compact, non-XML syntax. XPath operates on the abstract, logical structure of an XML document, rather than its surface syntax.

Filter by
Sorted by
Tagged with
0
votes
0answers
45 views

Verify links in article within the web page / selenium web driver

I have to verify the links mentioned in article within web page. There are too many links in the page but I have to verify just the links specified in the article content. https://techcrunch.com/2019/...
0
votes
1answer
421 views

Dynamic XPATH by for loop in selenium web driver

I'm trying to write dynamic XPATH by for loop in java selenium WebDriver but I couldn't do it. There's a webpage and I have to print the string content which are in the xpaths mentioned in follow. /...
2
votes
2answers
102 views

How can I find element and insert text on this page?

The problem is that I cannot find and enter the text in the fields <input onkeyup="$('#firstname').val(this.value);" type="text" class="is_required validate form-control" data-validate="isName" id=...
2
votes
3answers
838 views

(C#) Selenium: How to extract information from html and write to a variable

I want to know how to get the HTML tag information and write to a C# project variable. Remember that I can not change the HTML because I do not have access. In the example below, it is necessary to ...
0
votes
4answers
724 views

Not able to click on menu using Selenium WebDriver Java

I am not able click on the specific element, which is in the image format. I have tried using available locators i.e id and image using XPath and remaining locators are same for all remaining menus. ...
0
votes
3answers
3k views

How to find element with li class inside span class in Selenium

Its name of tab. I have tried by Link-text but it's not working. I have tried d.findElement(By.linkText("Clauses")).click(); It shows error Exception in thread "main" org.openqa.selenium....
1
vote
1answer
107 views

(C#) Selenium: How do I choose an option within a ComboBox?

How do I select the "C" option of my ComboBox "opcao_pesquisa"? <form name="Form1" method="post"> <input type="hidden" name="operacao" value="1"> <input type="hidden" name="d" ...
0
votes
1answer
112 views

xPath (SCRAPY) Python using two attributes together

For example : <html > <body> <a class="abcd" title="he is Gandhi"> he was good </a> <a class="bcde" > he was very good </a> <a class="abcde" title ...
2
votes
2answers
62 views

Selenium: How do I use the button of my HTML in WebElement?

How do I locate my button that has the text Pesquisar > in my Selenium WebElement? My HTML: <div style="font-size: 10pt; font-weight: bold">Portais </div> <hr> <form name="...
0
votes
1answer
47 views

Tidy HTML with BaseX

How do I tidy this HTML for baseX? Working from a basic example. Looks like the HTML isn't valid, or at least baseX has apparent problems with parsing it: thufir@dur:~/NetBeansProjects/...
2
votes
1answer
83 views

Scrape items from an HTML list

When Catalog receives a fragment for a book category, it seems to my eyes, to be just list items. For space, I didn't include that output. How can I ensure that only categories which belong to the ...
2
votes
0answers
160 views

decompose an HTML list with page fragments

note: Looking for simplest possible example of PageFactory and fragments. I've been referencing an article which uses additional libraries I wasn't aware of. The desired structure: Where there's ...
1
vote
1answer
196 views

how to Iterate a List of links?

This "Books" link shows that it has the following xpath: /html/body/div/div/div/aside/div[2]/ul/li/a Then follows the catalogue categories: Travel, Mystery, etc. Reading the xpath above I see ...
1
vote
2answers
806 views

NullPointerException when using @FindBy

I'm getting a NullPointerException when trying to use @FindBy because the object reference is only declared and not instantiated. What is the usage? The docs give example declaration but no instance ...
0
votes
1answer
393 views

xpath query for specific String value

My project is crashing with: Element info: {Using=xpath, value=//a[contains(text(), 'Books')]/@href}. The output (crash): thufir@dur:~/NetBeansProjects/com.toscrape.books.selenium$ thufir@dur:~/...
2
votes
3answers
5k views

XPATH : text()='BUY NOW' is working but not contains(text(),'BUY NOW')

In Flipkart page, I searched for Apple ipads and clicked on first search result. Here, I wanted to click on 'BUY NOW'. Typical page looks like this: I used the following xpath and it worked: //...
3
votes
2answers
227 views

How to find the xpath for the link given below?

Please help me find the xpath for the page https://www.seleniumhq.org/download/ In this page there is a para "Selenium Standalone Server". In that I have to find the xpath for Download version link "...
1
vote
1answer
154 views

How to speed up Java Selenium Script,with minimum wait time

I'm currently working on a java selenium Project, which is usually a small script where I have to check for each element for it's presence and based on that some actions are triggered but our main ...
2
votes
2answers
85 views

How can we automate the fields if there are multiple data components are present on UI and we need find inside elements

I am new to selenium. following are some info. Can someone guide me to create xpath and this is the approach we are using to maintain the UI elements unique, so for this code, will selenium help to ...
0
votes
1answer
3k views

how do I get text value outside of any tag in html, through selenium in java

I have text,which is not enclosed inside any of the HTML tag but is wrapped in between two HTML tag as shown in below image, how do I get the value 38 in this case, through selenium in java. below is ...
0
votes
2answers
341 views

Selenium can't locate element by xpath

I am using Selenium and attempting to locate an element (table cell in a web app) by xpath. However, I am getting a NoSuchElementException when running my test cases. I am positive that the xpath ...
0
votes
2answers
679 views

Selenium: Why find_element_by_partial_link_text finds the first match only?

What I want to do: I want to click all the links where partial text = "105611A5C7B9_Logs_" Example: First Link Text = 105611A5C7B9_Logs_11-15-18-06-04PM.tgz Second Link Text = ...
1
vote
5answers
4k views

XPath to select label plus hidden radio button option using WebDriver

I am unable to write the correct XPath to select the title "MRS" for below code. I am using below code, but unable to execute it. driver.findElement(By.xpath("//div[@value='MRS']")).click(); Getting ...
0
votes
1answer
36 views

How do I find xpath for “Invalid License!” text in the HTML code shown

<div id="content" class="content"> <div class="container col-lg-12 col-md-12 col-sm-12 col-xs-12"> <div class="alert alert-danger alert-dismissible" role="alert"> <button ...
0
votes
2answers
210 views

How to click on an iOS MobileElement (button) which is dynamically changing using XPath

Below is the XPath- //XCUIElementTypeButton[@name="8/13"] The numeric value in the above XPath changes and is not static. There are more then 10 buttons on the screen, I want to click on the first ...
1
vote
2answers
451 views

The xpath for clicking edit button is not working in Selenium Java

HTML Code: <button onclick="root.handleOnClick( document, this );" id="Edit_edit::0" title="Edit" name="Edit_edit::0" class="navbar-btn btn btn-default btn-sm cs-btn" type="button">Edit</...
0
votes
2answers
213 views

Unable to locate Text element using XPath in Selenium [closed]

This is my HTML page and I have some problem with my automation code and it is not able to locate the element and this is the XPath I used: @FindBy(xpath="//div[contains(text(),'Done')]") HTML Code: ...
0
votes
1answer
212 views

Unable to click a delete icon represented in my cart

Here is my HTMLCode: <span onclick="cart_delete('0')"> <i class="fa fa-trash-o" aria-hidden="true"></i> </span> I tried with below code: driver.findElement(By.xpath("//span[...
0
votes
1answer
143 views

Finding xpath using tr/td

http://newtours.demoaut.com/mercuryregister.php Find xpath for first name and last name is very difficult. How Xpath can be used if there is no id , tag or class available. ...
0
votes
2answers
3k views

How do I use XPath to find the values of cells in a table

The structure of the Html I need to work with is shown in the screenshots below. I need to get the values of the first and third column of each data row in the table. There is nothing unique about ...
0
votes
1answer
69 views

Locating unique element from a set of elements that only differ by a random string contained in the id attribute

I am trying to locate and loop through a set of elements that contain an id that only differs by a contained string. This contained string is not known prior to the test. My current attempt is to use ...
0
votes
3answers
477 views

Unable to click on link - no element found exception using Java selenium webdriver

I am using Selenium webdriver with Java. I need to click on link - Register New Consumer. HTML: <a href="/int/cdms/registrationType.do" target="_self">Register New Consumer<br> ...
0
votes
1answer
827 views

C# Selenium - How to write a conditional statement with multiple elements/xpaths

I have a problem and having trouble to finding a solution. Problem Statement: Navigate to a webpage and check if three checkboxes are selected. If not, I'd like to select them (if only one is ...
0
votes
1answer
76 views

Sharepoint Automation

I am trying to automate SharePoint test cases. I am finding an issue while finding an element locator for actual result, updated by, update date. Does anyone know how to find the locators? HTML: <...
0
votes
3answers
40 views

Regarding taking Xpath [duplicate]

Kindly follow the below HTML code. I want to get the text "DefaultBP" in between the tag. If I using this XPath "//div[@class='workspace']//h1", all the texts including tag such as "Export", "Import"...
1
vote
5answers
5k views

Unable to click button using Selenium Webdriver Java

I am trying to click a button through webdriver. After inspecting the button element it highlights to the following: XPath: /html/body/div/div/main/div/div[2]/div/div[2]/table/tbody/tr/td[4]/form/...
1
vote
2answers
574 views

How to go to a certain Xpath by Searching a Text in Selenium WebDriver

I have below HTML which is having a table with 15 rows (below are the 2 rows for example)- <table id="task" style="width:100%" class="border"> <thead> <tr> <th>Task </th>...
0
votes
1answer
3k views

How to resolve InvalidSelectorException in Selenium?

selenium.common.exceptions.InvalidSelectorException: Message: invalid selector Unable to locate an element with the xpath expression .//*[@id="Toolbar"]/table/tbody/tr/td[2]/a[1]/span)[3] because of ...
0
votes
2answers
300 views

Verify Text using CSS or Xpath

I am new to automation, Selenium Web Driver and am practicing code using Amazon. I want to verify my logged in user name (Hello, Nichole) on the Amazon Home Page but anything I enter using CSS or ...
0
votes
1answer
3k views

Getting Invalid Element State Exception

I am trying to clear text from <div> section using XPath using the below line. Clear Element Text xpath=//*[@id="intro-overlay"]/div I am getting below Error: ...
0
votes
1answer
2k views

Locating Inner Text with CSS or Xpath in Amazon

I am teaching myself automation with Selenium web driver, and thought a good way was to learn off an ecommerce site such as Amazon. I am trying to locate inner text with CSS and used the following to ...
0
votes
2answers
3k views

How to get count of dynamic 'div's' nested inside a each 'td' tag?

I have table which have several <td> tags, again these tag have nested <div> tag. But the number of <div> are dynamic. Means, for each <td> tag number of <div> are ...
2
votes
5answers
803 views

Xpath: which is much more reliable source - Chrome or Firefox?

On Google chrome, inspecting an Element and copying it's xPath gives me the following value //*[@id='Body']/app-root/app-generic-product/section[2]/div/app-product-summary-list/app-product-summary[2]/...
0
votes
2answers
981 views

How to identify elements on DOM without using element name

<span class="" data-aura-rendered-by="2565:0">Active</span> <!--render facet: 2567:0--> <!--render facet: 2568:0--> </label> == $0 <input type="checkbox" checked="...
-1
votes
1answer
817 views

How to create Xpath to read text between span class?

HTML: ...<div class="ArticleCount__articleCount___lQ5f1"> <span class="ArticleCount__text___1c2Rn">Showing</span> 9 <span class="ArticleCount__text___1c2Rn">of</span> 23 ...
1
vote
2answers
869 views

Can we use css properties (like background-color) for locating an element when that property is not part of the element attributes

Can we use css properties (like background-color) for locating an element when that property is not part of the element attributes? Like If I have to get the xpath or css of this element, either I ...
-2
votes
3answers
3k views

Unable to find the element using XPath

XPath: //*[@id=\"clB\"]/div[1]/div[1]/a/div Exception: Exception in thread "main" org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the xpath ...
1
vote
3answers
63 views

Locating element on DOM pages when element type changes, e.g. INPUT to A

//a[@type='text'][contains(@class,'form-control')][contains(@name,'projectsurvey')] Do we have a way when the element name changes from input to some other For Example : class then definitely script ...
0
votes
1answer
7k views

How do I use find_elements_by_xpath to only get some elements in python selenium?

How should I use driver.find_elements_by_xpath() to get all the data-row elements that I boxed in the picture. I do not need the other tr tags. In my current code I just check all the tr tags and ...
0
votes
1answer
4k views

How to create an Xpath for a checkbox?

I've tried the following xpath but none of them work. The id is listed differently everytime. Next to the checkbox is this word " poetin alfa" - //input[@type='checkbox'][@value='on'] - //*[@id='id1'...