The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
5
votes
3answers
102 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
26k 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
671 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
42 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
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")]')); ...
0
votes
1answer
164 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
313 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
6k 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 ...
1
vote
3answers
760 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
5k 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
592 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 ...
2
votes
4answers
14k 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
4k 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
1k 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
3answers
3k 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 #:']][...
-4
votes
1answer
2k 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
147 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
3k 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
1k 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
101 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.
0
votes
3answers
500 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='/...
0
votes
2answers
958 views

Help in locating an image button inside div element

So I am trying to automate a test and my issue is that I cannot point to the button element which is actually an image inside of a div. I tried going down the hierarchy but no luck. this is the code I ...
0
votes
2answers
2k views

Not able to locate the web element with partial xpath and text [duplicate]

I have web element set like below .. <div class="dxnb-headerCollapsed" id="ctl00_LeftPanel_LeftNavigationMenu_nbMenu_GHC1"> <i class="fa fa-handshake-o fa-2x fa-fw" style="">&...
-1
votes
2answers
125 views

WebElement click does not work in chrome browser

I have tried below code : driver.findElement(By.xpath("//*[@id='content']/div[2]/div/div[5]/div/div/res-view-activity/div/div[1]/a[2]")).click(); This works when using Firefox, but does not work ...
1
vote
1answer
2k views

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

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

How to find an element which doesn't have proper attribute

I need to click on an element which is inside the div tag. I tried using the xpath which when used detects the element both in console and in the Katalon ide. But when the script is run, it doesn't ...
0
votes
6answers
14k views

How to find XPath inside <td>

I need to find the xpath for the line in the image with highlighted text. The highlighted text/number is dynamic. Once I find the xpath, I can save it in a variable using getText(). Kindly help me. I ...
-3
votes
1answer
297 views

Unable to locate element using this XPath [closed]

This is my xpath - //*[@id="284623"]/div[4]/div[4]/img Unable to locate element using above XPath. Please help..!
-1
votes
1answer
332 views

How to write XPath if my ID is changing continuously? [duplicate]

//*[@id='post-9505']/h3/a/time //*[@id='post-9466']/h3/a/time //*[@id='post-9517']/h3/a/time In this id number is changing continuously, so how can i write dynamic XPath? please help me to write ...
0
votes
2answers
2k 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" ...
0
votes
1answer
2k views

Xpath is not working using contains and starts with having random values

XPath is not working using contains() and starts-with() functions for below ID id="u_0_3" I have tried with: //*[starts-with(@id,'u_')] - startswith //*[contains(@id,'u_')] -contains Can ...
1
vote
1answer
407 views

Continue WebDriver test execution, when element is not visible/clickable

I have a Selenium WebDriver based testsuite. XPATH on site are changing sometimes, so I would like to use this to identify which XPATH has to be refreshed. So in case element isn't visible or not ...
0
votes
2answers
252 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" ...
3
votes
1answer
214 views

Find anchor (has other html elements) with specific text

I am trying to find the list item based on the contents in the anchor. I tried using the following xpath //li/a[contains(., 'India')] It is working for unique items, But here, it is matching more ...
-1
votes
4answers
8k views

Button won't click even though I can see it's taking me to the button when doing automation

My code which takes me to the button and highlights it (I'm running java scripts within Eclipse) driver.findElement(By.xpath("//button[contains(text(),'Save')]")).click(); My HTML code <button ...
-1
votes
1answer
566 views

How to handle if XPath are different for multiple sub-menu options [duplicate]

I have situation when i have click main menu options it will be display 10 different sub-menu options. In all sub-menu section is available 2nd sub-menu options which is available more than 20 menu ...
1
vote
1answer
2k views

Selenium fail to find the html tag inside iframe after selecting the frame

I am trying to edit the message body area of outlook mail. The steps I have followed so far are, Login to outlook web app Double click and open the mail (the mail is opened in a seperate window) ...
0
votes
2answers
3k views

Button click is not redirecting to next page in selenium webdriver

I am trying to do Bus Search first on Travelyaari.com and then Modify the Bus Search, The Modify Search button seems to be clicked, however, previous Bus search result page is getting loaded and my ...
1
vote
1answer
85 views

XPath error for Google Sheets

I want to get live data from a website. I select inspect and copy the XPath from where I want the data to import, but I get an #ERROR!. =IMPORTXML("https://www.jamstockex.com/market-data/listed-...
3
votes
3answers
136 views

Xpath Axis Selection [closed]

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[...
7
votes
4answers
3k views

same xpath on the page with dynamic ID selenium java

I have a problem with the two same XPath with dynamic ID on the same page. I have tested for selenium in java, when I need to confirm button on delete upload file. Instead of this, test first submits ...
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"> ...
1
vote
0answers
123 views

How to inspect an element with multi attributes by OR operator in Page Objects model in watir?

I have a problem when trying to find an element with different attribute as sample bellow <i>bold</i> Sometime <i class='icon'/i> I want to try inspecting this element with OR ...
-1
votes
2answers
4k 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 ...
0
votes
1answer
5k views

Matching multiple classes with an XPath expression

I am trying to automate the Scenario of NSE India https://www.nseindia.com/. I am trying to capture the Nifty50 increment or decrement value using Xpath as //nobr/span[@class='red'][1] when sensex is ...
0
votes
1answer
44 views

Can someone help me to correct this date picker excerpt [closed]

I need help to correct this excerpt. The excerpt is not working right now. I have attached the screen shot here. //h3[text()='Alert Expiration']/..//table[contains(@class,'vdl-calendar__grid') and ...
-1
votes
1answer
340 views

Capturing the xpath/locator of the Edit Status in Facebook

I am trying to Post a status in FB using selenium. But i am not able to correctly locate the Edit status text and getting NoSuchElementException. I have tried different xpaths, which are correct too ...
0
votes
1answer
106 views

Are SelectById, SelectByClass and SelectByName just special cases of general SelectByTag?

2 questions in 1: 1) In all the Selenium tutorials they divide the ways of finding elements in the way like: 1. By ID 2. By CLASS 3. By NAME 4. By TAGNAME 5. By CSS Selector 6. By Link 7. By XPath I ...
1
vote
1answer
17k 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
1answer
115 views

I cannot find the locator for this dropdown list of below html code and PICture [closed]

Below is the html code: <li> <a id="inputBox" class="menulink menuhover">Scotia Mortgage</a> <ul id="listOptions" style="overflow: visible; display: block; height: 148px; ...