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
1
vote
3answers
346 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
480 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
405 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
370 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
3answers
913 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
5answers
1k 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
432 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
4answers
3k 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']
5
votes
3answers
103 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, ...
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.
-3
votes
1answer
726 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
45 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
178 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
353 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
7k 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
858 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
6k 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
618 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
15k 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
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
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
4k 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
157 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
4k 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
105 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
528 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
997 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
129 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
112 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
16k 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
302 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
349 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
425 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
254 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
223 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
9k 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
602 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
87 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
138 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"> ...