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
2
votes
4answers
96 views

How different the execution would be if we use ID or xpath with ID?

Since we say that IDs are faster and are preferred over XPaths, how different would the execution of the following be? driver.findElement(By.xpath("//button[@id='Save']")).click(); driver.findElement(...
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 ...
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 ...
2
votes
4answers
696 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="...
2
votes
2answers
223 views

How to locate XPath for given tag? [closed]

I am trying to automate one of site and the below are the HTML code for same: <a href="http://register.rediff.com/register/register.php?FormName=user_details">Create a Rediffmail account</a&...
2
votes
2answers
7k 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(...
2
votes
2answers
101 views

What is the best way to automate a system, where the XPath is not static?

I have to automate a system, which changes its ID's from time to time, and the XPath is not static. What is the best way to automate this kind of system?
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 || ...
2
votes
1answer
33k views

How to use multiple condition in xpath?

I have tried with the xpath like "//HTMLtag[contains(text(),'Yourtext') and contains(text(),'Yourtext')]", but this case worked for the particular html tag and not for the different tags. how to make ...
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
815 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 ...
2
votes
2answers
30k 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.
2
votes
2answers
4k views

Selenium webdriver - Cannot find button inside modal

I cannot click on this button contained in a modal this is the html <div class="col-md-6 col-sm-6 col-xs-12"> <button class="btn modal-button full-btn" id="saveexit" type="button"> ...
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="...
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: //...
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 ...
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 ...
2
votes
1answer
402 views

Assertion about size of an XML tag

Community, I'm trying to add an assertion for an XML Response that verifies the size of the info of one of the tags. So for example, this is my response: <description>This is your password</...
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. ...
2
votes
2answers
219 views

Selenium Selenium.Core v1.1.4322 - XPath not working

I've got the following XPath expression's working in firebug, that returns the correct element(s): $x("(//input[@class='intervalInput timeInput'])") returns two elements. $x("(//input[@class='...
2
votes
1answer
70 views

Selenium python checkbox by span class

I have an issue with checkbox check in selenium python, I want to make not exact xpath, but something like I did earlier in the code : browser.find_element_by_xpath(".//span[contains(text(), 'Dalej')]"...
2
votes
4answers
11k views

Selenium webdriver select element “next to” already selected element

Hi I'm using selenium on Java and here's the situation: <article> <div class="inner-article"> <a style="height:150px;" href="link"> <img width="150" height="150" src="...
2
votes
2answers
762 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
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'...
2
votes
3answers
738 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 ...
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[...
2
votes
4answers
182 views

Selenium- Unable to save dynamic paths in the list..list shows 0 as size

import java.util.List; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium....
2
votes
2answers
2k views

AND/OR Operation in Contains Assertion in SOAP UI

There's one tag in my XML response whose elements (JSON Data) always come in different order. Is there any way to create a contains assertion with AND/OR operations or should I just use a Script ...
2
votes
2answers
5k views

How to add HTML/text content of a <div> into an array/list?

I am new to selenium and working with xpath. I am using selenium and java to write automated tests for chat messaging web application. I am looking for a way to take a webElement which contains ...
2
votes
2answers
96 views

Looking for a API/tool to validate html snippets

Our UI designers would like to validate that the HTML they specify should appear on a page does, in fact appear on the page as generated by a .jsp. They need to specify a particular set of HTML nodes ...
2
votes
0answers
32 views

How to handle n number of dropdowns fields with same xpaths

I have two drop down fields which are parallel and there is button as well from where more fields can be addded at every row. There is no any limit on the fields to be added and have to fetch values ...
2
votes
0answers
115 views

How to get text from span that is not in Latin Alphabet? [closed]

I'm having difficulty getting text between span tags. The problem is that the said text is not written in Latin Alphabet. I have no problems using UTF text as part of xpath locator. My xpath looks ...
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 ...
2
votes
1answer
1k views

select random cursors on map using selenium ide

I'm using google map api in my site and I want to test the cursors on map using Selenium IDE. Now I use this code and it works fine: clickAt > xpath=(//map[@id='gmimap85']) but it tests only one ...
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 ...
1
vote
3answers
3k views

How to handle dynamically updated params in XPath queries in Selenium?

I am new to Selenium IDE. In my Web application, while playing back the recorded events, some internal id in XPath expression gets changed dynamically. E.g.: (//*[@id='edit_1_undefined']) in this ...
1
vote
1answer
52 views

Same Xpath expression returns different results

I understand that for the below xml the xpath expression "//span[position()=1]" returns the first span element anywhere in the document: <div> <span>qty</span> <span>price</...
1
vote
2answers
148 views

What are the types of Xpath expressions for web application automation

What types of Xpath expressions can I use when automating web applications? I need to know different ways of finding elements so that if I can't use an ID I can always locate the element I need to ...
1
vote
4answers
71k views

How to use Xpath 'contains()' function to locate a Web element in Selenium Webdriver?

I am a beginner in learning Selenium WebDriver and XPath. I am trying to get the "<td>" Element of the Nested Table which Contains string '7-8-9.' Following is the HTML page code: <!DOCTYPE ...
1
vote
2answers
3k views

Need help with passing a variable in xpath

I am automating my application using Protractor. For one of the elements, I am using xpath, which is as follow: element(by.xpath('//ul[@id="employee-list"]/li[contains(text(),"Master Shifu")]')); ...
1
vote
4answers
5k views

How to fetch the text from span tag?

I need to fetch text 'Finance' from the span tag below to compare that with another value which is saved in a file.But I am not able to fetch that. <span class="panel-text col-md-8">Finance</...
1
vote
1answer
19k views

How to use a regular expression to identify xpath of element with autogenerating id

I need to access this element: <input id ="combo-1105-inputWrap"> The 4 digits in the xpath are autogenerated per browser session. I need to find that particular xpath and key in the data. ...
1
vote
2answers
886 views

Identifying objects in Selenium

I have been asked on interviews about identifying objects, so I got a little confused. All of the below questions are related to identifying elements, so I combined them together: Is there any other ...
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
2answers
51 views

How to resolve 'Cannot convert from void to WebElement' error in Selenium

I am getting below error: Error: Type mismatch: cannot convert from void to WebElement. CODE: WebElement uploadElement = (driver.findElement(By.xpath("//input[@id='HorizontalLogoPath']"))).click(...
1
vote
3answers
83 views

How do find XPath when only value is given in the source code?

What will be the XPath of a 'Search' button from the expression mentioned above?
1
vote
3answers
372 views

Select element by containing text without XPath in Selenium

There is a great discussion on what makes a good Selenium locator here. It seems many testers prefer CSS to XPath for locators, for various reasons. And that goes for me, too. But, it is often ...
1
vote
3answers
343 views

Xpath returning 2 nodes. I am trying to return 1 node

I am using XPath to search the below web elements. My XPath command returns 2 nodes. I am trying to retrieve 1 node. Unfortunately, the web page I am testing has the exact same elements and text. Can ...
1
vote
1answer
537 views

Not Able to Login to Ebay using Selenium

I am trying to Login to Ebay site using Selenium. I have successfully identified the user name and password Text boxes using Xpath (and validated the xpaths using the Firefox Eval tool in Firebug). ...