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
0answers
12 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
0answers
16 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
2answers
34 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
23 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 = ...
0
votes
4answers
91 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
26 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
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 ...
1
vote
2answers
52 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
58 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: ...
0
votes
1answer
45 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
50 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
76 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
28 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
73 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
57 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"...
0
votes
4answers
230 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
81 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
63 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
86 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
292 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
266 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
346 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
146 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
117 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
208 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 ...
0
votes
2answers
144 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
324 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
60 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
1k 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
581 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'...
1
vote
3answers
77 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 ...
0
votes
5answers
135 views

Unable to locate element using XPath getting NoSuchElementException

I am unable to click on logout link in my web page using XPath. XPath: html/body/div[1]/span/div[1]/a[1] I See my code in an attachment: .
1
vote
3answers
101 views

How do I get the same result for xpath1 OR xpath2 in Selenium?

How to get the same result if condition: //div[@class='lng-info']/h5[text() = 'PMP'] or condition //div[@class='lng-info']/div[@class='price'] is true ? How do I write a single xpath expression ...
0
votes
2answers
154 views

Couldn't find the x path of filter in selenium webdriver

Tried this: WebElement searchDropdown = driver.findElementByXPath("//span[@class='selected']"); Select searchFilter = new Select(searchDropdown); searchFilter.selectByVisibleText("...
0
votes
2answers
306 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
3answers
287 views

How to locate “Login” button of Flipkart bootstrap login page? I tried in many ways, but still unable to locate element

Below are three options I tried, but I'm not able to locate Login button. When I tried using seleniumIDE, I got this xpath=(//button[@type='submit'])[2] But its not working in Webdriver. Can someone ...
1
vote
0answers
122 views

Unable to Switch to iframe in IE

Code Trails: driver.switchTo().defaultContent(); List<WebElement> before = driver.findElements(By.tagName("iframe")); for (WebElement t : before) { System.out.println("iframe" + t....
0
votes
3answers
88 views

Xpath is Unable to Locate Element.

Can anyone help me in writing xPath for below image, I wrote one but it's not working. My xPath is //li[@class='active']//a[@class='dropdown-button btn']
0
votes
0answers
58 views

Test case execution hangs. No exception is thrown even when xpath for an element shows No matching nodes

I have a drop-down which should display a list of items. Somehow, the drop-down fails to appear and provide me with options. When I run my test case, the drop-down does not appear. I have used and ...
5
votes
3answers
98 views

Which Xpath is more suitable?

xpath 1 : //div[@class='abc'][.="xyz"]/parent::*/div[2]/div xpath 2 : //div[@class='abc'][.="xyz"]//following-sibling::div/div Above two xpaths are pointing same element. Which is better and why, ...
1
vote
2answers
5k 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.
-3
votes
1answer
200 views

XPATH FACEBOOK How can i get xpath or css selector ? - selenium/java [closed]

I automated some facebook functions for pratice selenium, but i can't click on search options. How can i try this ? Search: elements:
0
votes
1answer
41 views

Xpath worked during script creation not working when replaying

HTML Tag: <a href="/candidate/updateprofile.html"> <span class="no-of-jobs">100%</span> <span class="grey-text">Profile Strength</span> Update your profile &...
1
vote
2answers
703 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")]')); ...
0
votes
0answers
121 views

XPath returns wrong element

Xpath returns wrong element I have a problem with xPath returning wrong element in code, but working as intended when i put it in my browser and search element with such xpath. The xpath that the code ...
0
votes
1answer
55 views

SoapUI Xpath assertion: match the exact length of the field

I need to match, exact length of a string and I'm using below code for that : declare namespace ns123='urn:lt:sb:xmlns:services:customers:customerinformationfile:GetCustByGlobalId:1.2'; matches(//...
0
votes
2answers
61 views

How to get the number of buttons within a div using webdriver?

I have trying to get the number of buttons(count) enabled in a web page using their class names. But I couldn't get it as I wanted. Always I get count as 0. int count = 0; try { ...
-1
votes
5answers
964 views

Unable to click on checkbox using Selenium & Java

please send me the full code I tried Some XPath and CSS: XPath: //div[@id='autofill']/div/label //div[4]/div/label CSS: div.col-md-1.checkbox.checkbox-primary > label* but using above ...