Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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 ...

0
votes
2answers
352 views

Selenium IDE type not saving text

I am trying to create an automation tool to test a salesforce platform. When I try to create a new form, the text is displayed but it's really just an injection from Javascript. Is there any way to ...
0
votes
1answer
35 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
168 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 ...
3
votes
3answers
102 views

Xpath Axis Selection

The following xpath selects siblings of selected context. But I'm confused about the following xpath expression: xpath://h2[contains(text(),'A few of our most popular courses')]/parent::div//div[//a[...
0
votes
2answers
89 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
2answers
64 views

Unable to locate Text element using XPath in Selenium

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: ...
3
votes
1answer
455 views

How to use Jmeter Xpath extractor for multiple run in dynamic API elements

XPath extractor response assertion passed first run but in second run it is getting failed because <name>pc</name> is not coming in API. How to skip this element if it is not coming in ...
0
votes
2answers
129 views

I am automating coop website and I'm facing problem while customizing XPath for add to cart button

I have customized an XPath for adding a product which has discount 30% for 2. Now I am facing problem while adding this into the cart. package sample; import java.util.ArrayList; import java.util....
7
votes
3answers
38k views

Webdriver: How to find the element using text() in xpath?

I'm new to selenium and HTML. I want to perform click operation for the elements "Users" and "Admins" as one after another. Below mentioned is the HTML code, unfortunately I can't modify it. <ul ...
0
votes
1answer
370 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
5answers
136 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 ...
2
votes
2answers
75 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
4answers
334 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/...
3
votes
3answers
45k views

How to find element by class name or xPath?

I have problems with finding this element: I tried these finders: IWebElement profilUploadPhoto = driverGC.FindElement(By.XPath("//button[contains(.,'submit')]")); IWebElement profilUploadPhoto = ...
0
votes
1answer
34 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 ...
1
vote
1answer
1k views

Unable to find element for a button in angular application through selenium webdriver

<span ng-click="addReqPage()" class=" wrapper-xs text-center cursor-pointer" tooltip-placement="bottom" data-toggle="tooltip" tooltip="Add Specification"> <!-- ngIf: ...
0
votes
0answers
20 views

Interact with dynamic JavaScript menu object using Selenium WebDriver

The issue I'm having so far is that some of the menus are created dynamically using JavaScript and don't have any html tags to interact with the menu's in order to automate the clicking on the menu. ...
0
votes
1answer
683 views

Selenium script on Pega Platform application behaves weird

I have identified web elements uniquely using customized xpath //table[@pl_prop_class='SOM-FW-PayMaineFW-Data-ProductGroup']/tbody/tr/th[1]/div/div/div[1] But, when I run the test script and ...
0
votes
2answers
40 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
27 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 = ...
3
votes
2answers
782 views

Dynamic XPath in Selenium - which input field keeps changing

I tried to find the XPath of a text field username and password, but it keeps on changing dynamically. I won't be able to use starts-with or contains in a findelement using XPath. Here's the HTML DOM- ...
0
votes
1answer
37 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 ...
0
votes
2answers
226 views

Selenium Java WebDriver Can not Find Element with xpath

I've a question, how can I capture the xpath in the case below? I tried this: driver.findElement(By.xpath("//*[@id='L2_auto_8']/div/a[1]")); and I tried: driver.findElement(By.xpath(//a[@href='/...
1
vote
3answers
361 views

How to solve java.lang.NullPointerException error in button click event?

I'm using Java,Selenium web driver and TestNG framework. I have a method to click a button in web page. But it didn't work. When debugging I could find xpath is not passed to the button. Then I tried ...
1
vote
2answers
57 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</...
1
vote
2answers
6k views

Selenium web driver - how to select child elements

What xpath can I use if the tag name in the code starts with li or span and they are child or parent. The trip id and the name locator didn't execute.
0
votes
3answers
82 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> ...
25
votes
3answers
142k views

A way to match on text using CSS locators

So I use xpath locators and slowly converting to CSS. I haven't found a way to do an exact match based on text. For example converting //a[text()='Log Out']. I know you can do css=a:contains('Log ...
5
votes
3answers
35k views

"Element is no longer attached to the DOM” StaleElementReferenceException when selecting HTML table row

I am using Selenium 2/WebDriver for automation. I have a table and am trying to select a row in it. When the test runs, I can see the row become highlighted as if it is clicked, but then immediately I ...
0
votes
1answer
48 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[...
1
vote
2answers
96 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
53 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
1answer
30 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 ...
8
votes
6answers
16k views

Selenium.click not working on some anchor elements

The application that am working on was recently revamped and as part of that a new JQuery calendar was introduced. I need to click on a link in the calendar to select the time and date. However, ...
-1
votes
1answer
81 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
1answer
75 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
27 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
39 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
votes
2answers
2k views

How to write XPath under tag: strong<> <br> after every <strong>

I am trying to find xpath of text 262567 of given below HTML code : <div class="lessthanhalf" > <h4> Listing</h4> <strong style="background: rgb(204, 136, 136); border: 2px ...
2
votes
5answers
11k views

How to write XPath if I have 'apostrophe' in my XPath element?

I came up in a situation where I have to identify an element using XPath and my element starts with apostrophe ('). I will give the example below. This is the usual way we write some XPath. By ...
0
votes
2answers
92 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
339 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
475 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 ...
0
votes
2answers
189 views

Unable to click image in Wordpress text editor

A test case where image and content are to be added in WP text editor under post section. I want to select the image that is uploaded in the editor but it always says "Unable to locate element" ...
2
votes
5answers
170 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
147 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
241 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 ...
-2
votes
3answers
397 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 ...
0
votes
2answers
1k views

Selenium — Unable to click the checkbox, error throws Element not visible

This is my html source: <div class="col s12"> <input type="checkbox" class="filled-in" d="corresp-checkbox" data-class="jrnlCorrRef" data-note- class="jrnlCorrAff" ...
1
vote
3answers
61 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 ...