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
0
votes
2answers
3k 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" ...
1
vote
3answers
68 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
6k 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'...
0
votes
1answer
10k 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
5answers
731 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
597 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
3answers
923 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
425 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("...
1
vote
0answers
518 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....
-1
votes
2answers
156 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 ...
5
votes
3answers
105 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, ...
0
votes
1answer
54 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 &...
-3
votes
1answer
1k 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:
1
vote
2answers
5k 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
222 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(//...
2
votes
1answer
418 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</...
4
votes
4answers
24k 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 ...
2
votes
4answers
17k 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="...
-1
votes
5answers
10k 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
2answers
789 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
1answer
303 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
vote
4answers
7k 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)) ...
-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 ...
-1
votes
2answers
124 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
2answers
200 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
5k 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
vote
1answer
26k 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. ...
4
votes
4answers
9k views

How to click a link when more than 1 exists?

I want to click the link in one container but the container contains two links having the same identifier. For example: <div id="container" style="height:88 px; width: 310px;"> <a class="...
2
votes
7answers
7k views

How to find the xpath locator for logout button?

We are currently working on a selenium project. Can you guys help me to find the xpath locator for the logout button in the application? Below is a screenshot of the code for the element for which I'...
0
votes
2answers
1k 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
3k 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="">&...
-3
votes
1answer
319 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
411 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
1answer
3k 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
470 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 ...
2
votes
2answers
6k 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
votes
1answer
757 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 ...
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 ...
1
vote
1answer
106 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-...
1
vote
3answers
452 views

Not being able to locate an element using contains() in xpath

I want to locate the element using Reject from the below: <span ng-click="moderatePost(post,'R')" role="button" tabindex="0"> <i class="icon-delete-cross f-s-20 show-hide"/i> ...
0
votes
1answer
8k 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
45 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
531 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
136 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
121 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; ...
1
vote
1answer
894 views

Trying to automate a date-picker- having issues locating dates in the past

I am automating an app using a blend of Coded UI and Selenium in Visual Studio. I have an app that uses a date picker (seems like it's using Bootstrap but not entirely sure). Using XPath, I can locate ...
2
votes
4answers
698 views

Xpath for sign out button

I am trying to find out XPath for this "Sign Out" button, can anyone help me?
2
votes
4answers
101 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(...