Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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
1
vote
5answers
3k views

How to locate the XPath of an element in eclipse accurately?

I am working on a project in which automation is done using Appium Tool. I felt it difficult to track the XPath of an Image or Textbox in Eclipse while scripting. Sometimes the XPath will be given as ...
2
votes
4answers
14k views

How to identify the web-element for a Text Box using Selenium for the dynamically changing ID

I have a input text box having id property and the HTML for it as shown below username:<input type="text" id="1234"><br> Id property is dynamically changing. when the page loads next ...
1
vote
1answer
1k views

Find XPath for dynamic numeric value in a web page

Looking for an XPath for a webpage where after every booking a Rel# generate. Need to validate the Rel# is saved in a different tab or not. So the HTML page says: I tried with the given xpath "//*[@...
2
votes
2answers
15k views

How can I dynamically create an xpath string in Python for a webdriver xpath selector?

I am writing a Selenium Webdriver test using python2.7 to use XPath to select a link node set. For each link, I need to change the href attribute using driver.execute_script to execute javascript. ...
4
votes
4answers
3k views

How to generate good locators for elements in Web pages?

This site contains many questions that are about finding the right locator expression (XPath, CSS, etc) for an object in WebPage or about troubleshooting problems related in invalid or dynamic ...
0
votes
2answers
10k views

Unable to find the element in selenium web driver

I am trying to run the below code but getting error. Can you please point out the issue import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa....
0
votes
1answer
6k views

How to get the XPath for all tables in a page?

How do I know or find the xpath for table? Or, even better, get the xpath for all tables in a specific page? I'm getting no_such_element when running: public void test() { String ...
2
votes
4answers
3k views

How to find an element that may be in multiple xpath locations?

In a Web page having the following xpaths. xpath1 = By.xpath(".//*[@id='gamepackage-game-information']/article/div/div[2]/span")).getText(); xpath2 = By.xpath(".//*[@id='gamepackage-game-information'...
-1
votes
1answer
48 views

Unable to customize xpath

I want to select all the products having rating 4.5, I could do that with the help received from StackExchange. Now I want to add the products with rating 4.5 to the cart. However, I am not able to ...
-2
votes
4answers
986 views

Unable to customize XPath containing span

I want to select all the products having rating 4.5 and add to the cart. However, I am not able to customize the XPath. I tried the below XPath: //div[@class='product-item__rating']/span This ...
2
votes
4answers
692 views

Unable to locate element as ID changes after refreshing the in Ebay login page

Using JUnit I'm attempting to automate the eBay login. I cannot select the email/username field because field changes id on refresh. Any ideas? input size="40" maxlength="64" name="962970435" id="...
0
votes
2answers
879 views

How to locate below element TableHeader using xpath [duplicate]

I want to locate element 'TableHeader' in given DOM, I am using XPath but getting an exception unable to locate the element. Xpath : //div[@class='PageContent']/table[1]/tbody/tr/td[2] Please have a ...
-1
votes
3answers
1k views

Appium - why does XPath not work (at all / as expected)

Consider my below test code for Appium (WinappDriver). As far as I know, these two locators should be equivalent. Yet the second one fails because the element cannot be found. Is there any reason ...
4
votes
4answers
8k views

Find first IMG element using XPATH

I am trying to find first fridge IMG element in a e-Commerce page but I could not find it alone, It's identifying all Images under First DIV.. Please share you thoughts I tried below XPATH, is there ...
1
vote
1answer
6k views

How to get nested web element in dynamic table using xpath

I have a table which is dynamic (so i can't use strict locator or paths) <tbody> <tr class="odd" role="row"> <td>Company</td> <td class="sorting_1"> <td>22222@...
4
votes
3answers
14k views

Selenium: :How to click a button using the button label?

In the HTML code like this: <a class="test-class"> <div class="test-content"> <div class="test-time" data-start="12:13pm" data-full="12:13 PM - 12:50 PM"> &...
3
votes
3answers
4k views

How can I select <ul> element when class is not active

How can I select "Fiyata göre Artan"? <div class="search-top hidden-xs"> <div class="destination-info hidden-xs"> <div class="search-sort dropdown open"><div class="pseudo-border-...
1
vote
1answer
399 views

NoSuchElementException: Cannot locate an element using XPath

I am getting XPath error. Already tried with many XPath's. But not able to resolve. Can anyone give correct XPath? XML: <form id="report-filter-form" class="report-filter-form" accept-charset="...
0
votes
2answers
507 views

Selenium is not recognizing xpath

When I attempt to search for the following element by XPath, Selenium does not find the the element. Not sure what I'm missing here. driver.FindElement(By.XPath("//input[@type='text']")).SendKeys("...
0
votes
1answer
124 views

Finding column with certain text works using xpath but fails with cssSelector

I was trying to locate table column containing text 'Name', and it fails while using cssSelector with 'Unable to locate element' but works with XPath. I tried all the 3 below options with different ...
3
votes
3answers
4k views

Correct CSS selector for selenium

Which css selector's correct for the following HTML code ? <li class="active editing" data-index="0"> <div class="view"> <input class="edit"/> </li> I'm trying to get ...
3
votes
2answers
3k views

What is the hierarchy to use for finding elements - ID, class, name, xpath?

What is the hierarchy to use 'find element' by ID, class, or xpath and so on. Which is preferred over which? For some elements class is being used - is that recommended?
2
votes
1answer
2k views

XPath 'following', 'preceding' method equivalent in CSS selecor selenium

I am converting my project element library from xpath to CSS. Some xpath expression written using 'following' and 'preceding' method. Like below. //div[@id='dashboard_right_now']/following::a[...
1
vote
4answers
9k views

How do I use a combination of attributes to select a button in Selenium?

I'm trying to get selenium to select a simple button that says next. I've tried XPath, CSS, and linktext and it still will not select it for me saying it cannot locate the element. Here is the code. ...
2
votes
1answer
4k views

Unable to click button Selenium Webdriver 3

I have a button I want to click, Selenium isn't giving me an error just stops. I've tried both xpath and css and it just stops. <a ng-click="login();" ng-disabled="loginForm.$invalid || ...
1
vote
2answers
581 views

How to select an item from a drop down list with same text appearing along with other text

I'm using selenium/java and have a drop down list for languages. This list contains multiple variations of "English" as you can see in the code below. I want to select just "English". I thought of ...
2
votes
3answers
736 views

Clicking on a Xpath

I have a back button on my web page which I need to click on from different places. In one page the back buttons xpath looks like: //property-list/ion-header/ion-navbar/button In another other page ...
3
votes
2answers
4k views

Cannot get attribute value when using xpath

I met a problem when I try to get an attribute of one tag. Here is the html code: <rect x="66.5" y="43.5" width="26" height="13" fill="#86E067" stroke="#ffffff" stroke-width="1" class="...
0
votes
1answer
331 views

JMeter - unable to return correct argument from list in XPath extractor

In order to generate HTTP requests to open a particular window, I need to obtain the component ID which is nested as an argument in onmousedown="Console.openView()" - in this example componentId= 1325....
1
vote
2answers
2k views

How to handle xPath returning Boolean instead of element?

I have xPath which returns boolean:true instead of finding an element on the page. Test page has a table with 2 columns and multiple rows. I'm testing if the rows have correct values. Below is the ...
4
votes
6answers
11k views

How to locate an element which is inside the iframe?

I'm new to automation testing (I'm using TestNG framework and Java language) I'm having trouble in locating an element which is inside iframe. WebElement iframeSwitch= driver.findElement(By.id("...
2
votes
2answers
752 views

Watir can't click on an element but can on irb

I have this command: @browser.element(:xpath => "/html/body/app/pages/div/div/div/div[3]/mi-perfil/div/div[3]/datos-personales/div/div[1]/span[2]").click There is no problem with the direction of ...
2
votes
5answers
12k views

Cannot locate button with changing ID in Selenium

I am working on a project where I have to locate a button. I have used XPath for that, but the button's id changes on every refresh, so I am facing a problem with that. Below is a HTML excerpt. Let me ...
1
vote
1answer
36 views

Unable to return both attributes using XPath in JMeter

I have the following xml: <td class="tableCell restrictionCell"> <span class="restrictionEditLink" rId="202">edit</span> &nbsp;<span class="restrictionDeleteLink" ...
0
votes
1answer
3k views

How to handle web element(enable button) having same Xpath?

I am working on a web page which having 3 web elements with 3 enable buttons and all buttons having same Xpath.so my need is to click on the button A and print the title of the webelement on every ...
3
votes
2answers
213 views

Identifying if an element is present or not using selenium

I have a SAVE button which is active only if I do some changes and then trying to save it. Otherwise its disabled. This is the html for that button: <button id="customize-site-save" class="...
1
vote
4answers
6k views

absolute Xpath is not working for Gmail login page

I have tested the Gmail login page and was trying to verify the Sign in label in the Gmail login page above the user name field. I am using FirePath to generate the Xpath. When I inspect the element ...
1
vote
4answers
11k views

Or Conditions in Xpath

I would like to find the Xpath, where the Text contains two names. I want my xpath to identify any one of the conditions below. e.g //div[text()='USER NAME' OR text()='USER ID'] or //div[text()='...
1
vote
3answers
2k views

what type of list does FindElements(ByTagName(“a”)) returns? [closed]

public static void main(String[] args) { // TODO Auto-generated method stub System.setProperty("webdriver.chrome.driver", "C:/Automation Stuff/ChromeDriver/chromedriver.exe"); ...
3
votes
3answers
7k views

What do I need to do if dropdown takes more time to populate 1st element from dropdown list?

What do I need to do if drop down take time to populate 1st element from drop down list? Select Cdropdown = new Select(driver.findElement(By.xpath("//select[@id='ClientId']"))); Cdropdown....
2
votes
4answers
4k views

Selenium — How to deal with 2 submit buttons and click on one of them?

The key HTML is: <div class="col col3 actionCol"> <button type="submit" class="booking fRight">Book</button> </div> but we also have other forms on the same page, e.g. for ...
0
votes
1answer
4k views

Java + Selenium + Frame :How to interact on element inside frame? [closed]

Problem - I've been trying to find the correct xpath for a element. I couldn't get the element in correct manner. Observation - I observed, It may be due to the element is located inside or under ...
1
vote
0answers
783 views

Hover Function not working in selenium webdriver for IE 11 browser [closed]

In IE 11, mouse hover is not working.It is kendo-control.Tried with each possible way.But anything is not working.The element is getting highlighted but it is not opening the list. I want to hover ...
1
vote
3answers
91 views

Notion of dynamic element

After watching videos on dynamic x-path in Selenium I want to ask: Q1: what does "dynamic" actually mean? Does it mean that the value changes at runtime or it can change over a period of time with no ...
1
vote
1answer
182 views

Which is more efficient mechanism for Object Identification in QTP - Xpath or Ordinal Identifiers?

Which is more efficient mechanism for Object Identification in QTP - Xpath or Ordinal Identifiers ?
2
votes
2answers
6k views

How to verify no /tr /td rows exist in a table?

I am verifying text using these Xpaths, $I->CanSeeElement("//tbody[contains(tr/td/div/table/tbody/tr/td[1]/text(),$this->Secondarycustomer)]"); $I->CanSeeElement("//tbody[contains(...
1
vote
1answer
355 views

How can I traverse to a particular element using xpath from a particular node? [closed]

Assume the following DOM fragment: <div id="ctl00_mainContent_ddl_destinationStation1_CTNR" class="search_options_menucontentbg" style="z-index: 999999; display: block;"> <div id="...
1
vote
3answers
10k views

Finding grandparent of an element using xpath in selenium

I want to click the parent of an element if the text within the child matches a certain string. I am using contains to find the text and :xpath,"../../" to find the parent. Here is ruby code: test=@...
5
votes
5answers
62k views

Locating element by link text (anchor tag innerHTML) or xpath fails in Selenium 2.0 Webdriver

I'm using Selenium 2.0 web driver. My script keeps failing whenever I try locating something in my page. It throws an exception whether I locate the element by LinkText or by XPath. driver....
0
votes
3answers
2k views

How to handle selectors that have ID's that keep changing? [duplicate]

I am using Fire bug in firefox browser to identify a unique id in the web pages using the Xpath feature. Sometimes the Xpaths are not unique, ie: the xpath id is dynamic and keeps changing as the ...