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
1answer
22 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
1answer
44 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
49 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
22 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
36 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
71 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/...
0
votes
2answers
45 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
54 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
57 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
101 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
85 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
96 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
106 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
62 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
69 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
66 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
166 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
58 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
429 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
191 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
64 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
98 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
81 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
102 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
171 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
133 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
80 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
75 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
45 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
92 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
2k 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
124 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
337 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
83 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
36 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
47 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
420 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 ...
0
votes
3answers
229 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 ...
0
votes
2answers
112 views

How to find a button using both xpath and button text?

I have three buttons withing a div. All three buttons belong to same class (class names are same). What I want to do is capture each button using its text (Buttons have different texts) and xpath of ...
1
vote
2answers
92 views

Unable to click on checkbox using XPath and CSS

I am not able to click the checkbox, I tried some XPath and CSS and id but I am not able to click on the checkbox HTML Code: <div class="row"> <table id="orderNoDropdown" class="table ...
3
votes
4answers
816 views

How to find the first occurrence of a field that exists in multiple places

I have code that includes the following label <label _ngcontent-c18="" translate="" for="517390_radio-button">Missing Applicant's Signature</label> However the label and the code for it ...
1
vote
4answers
426 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
315 views

Not able to check the checkboxes on a javascript page

Here is the code I used to select the checkboxes selectAllEmployeeInputRequired() { this.scrollToAndClick(this.employeeInputButton); return browser.wait(this.isVisible(this.employeeInputModalForm)) ...
-1
votes
2answers
488 views

How do I get particular textNode value of a DOM with Selenium

Hello I am trying to find Load # detail from this site. Also You can refer screenshot too. I have tried with xpath : //div[@class='equipment_item']//text()[preceding-sibling::strong[text()='Load #:']]...
-5
votes
1answer
272 views

How to write XPath under tag: strong

I want to red text under strong tag I have written XPath like: //section[2]/section/div[1]/div/div[1]/div[2]/text()[1] Here is the HTML code: <div class="listing-info"> <h4>Listing ...
0
votes
2answers
83 views

Can any one explain this xpath

Anyone can you please explain this xpath please. why we use '"+filterBy+"' rather than "+filterBy +" in this code segment. (I just simplify the code.this not an original one.) String filterBy = "Hio";...
0
votes
2answers
435 views

Dynamic ID locating element [duplicate]

New to Automation , I am using selenium with JAVA. I have come across a stumbling block our developers do not assign ID to our elements and JFS assigns it own ID , however the ID's are dynamic and ...
1
vote
1answer
169 views

Selenium Python Bindings - Accessing Submenu Items

I am using Selenium to write unit tests for a website to test scientific software. The backend uses Flask to generate a sidebar where each project is clickable with a dropdown menu. You can only open ...
-1
votes
2answers
61 views

Not able to find the Xpath, really complicated for me. Need help

i am not able to find the xpath for a text box and get the value from it the code is here. please help me find the xpath to locate the box and get the value from it.