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
11 votes
4 answers
97k views

Webdriver: How to find the element using text() in xpath?

I'm new to selenium and HTML. I want to perform click operation for the elements "Users" and "Admins" as one after another. Below mentioned is the HTML code, unfortunately I can't modify it. <ul ...
4 votes
3 answers
2k views

How to use Jmeter Xpath extractor for multiple run in dynamic API elements

XPath extractor response assertion passed first run but in second run it is getting failed because <name>pc</name> is not coming in API. How to skip this element if it is not coming in ...
0 votes
1 answer
23 views

Testing load of a highchart using python and selenium

I am writing a program that must screen some charts, the issue is that I do not know how much time a graph expends to load, it could be seconds or minutes. How can I make an appropriate wait, that ...
0 votes
1 answer
943 views

Unable to find XPath for mouse hover

I can't find my XPath so that I can't run the code. Can anyone solve this issue? I have to do mouse hover manage content then click on content Library: package TestNG; import org.testng.annotations....
0 votes
4 answers
5k views

Selenium - How to remove &nbsp from my text value

I am trying to use this xpath to find the number of elements that have a value between X and Y. The problem I am facing is since there is &nbsp in the HTML, and the code doesn't detect the text ...
1 vote
7 answers
11k 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
1 answer
471 views

How to select city based on city name in mat-option-text?

I need to find a specific city from a drop down list. I have tried using the xpath but the id number for the city keeps changing. The element from the website is below: <mat-option role="...
1 vote
3 answers
3k views

Selenium auto-selected the second element returned using the findElement method

As per the below code, I navigate to a specified URL and select the values in the from and to field. The xpaths mentioned in the 3rd and 4th line, each returns 2 instances. In the third line, ...
1 vote
2 answers
826 views

On selecting the radio button how to get the text of the selected radio button where the text is in the next column

On selecting the radio button how to get the text of the selected radio button where the text is in the next column I randomly select the radio button and then i need to Store the selected Radio ...
-1 votes
1 answer
25 views

Microsoft Account SignIn button cannot be clickable (Java Selenium Excel)

This is my code public void AccessLogin() throws IOException, InterruptedException { WebElement oauth = driver.findElement(oAuth); oauth.click(); driver.get("https://login....
0 votes
1 answer
59 views

How to find an unnamed button belonging to a certain h2 entry XPath

(I am a bit of a StackOverflow newbie, so please forgive any beginner mistakes and let me know what to improve in the future) I am trying to select the highlighted button in the appended picture. ...
0 votes
4 answers
4k views

Not able to click on menu using Selenium WebDriver Java

I am not able click on the specific element, which is in the image format. I have tried using available locators i.e id and image using XPath and remaining locators are same for all remaining menus. ...
1 vote
2 answers
1k views

XPath 'list' object has no attribute 'click'

I'm trying to select a checkbox on the following public web-page using Selenium XPath from Python and click it to change the checked status. http://simbad.u-strasbg.fr/simbad/sim-fout For example, the ...
0 votes
2 answers
1k views

How to click on an iOS MobileElement (button) whose attribute "name" is dynamically generated on the run 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
1 answer
181 views

I can't find element in a HTML file with XPath

I am trying to get the name and the price information from this website with XPath. When i write my XPath expression down in the search bar it locates correctly in the chrome. But in VSC it doesn't ...
3 votes
3 answers
567 views

Why doesn't my XPath find my element on the page?

I am trying to retrieve the content of the header and each chapter which is a repetitive structure as you can see below. For this am using Selenium and C#. My attempt, using xpath, is this: string ...
0 votes
2 answers
17k 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
1 answer
217 views

Python Dryscrape - how to select child element?

I'm working on a project with www.NJMLS.com. I'm trying to extract email of agent name "Edward An": import dryscrape as d d.start_xvfb() br = d.Session() br.visit('http://www.njmls.com/...
0 votes
2 answers
4k views

Finding sibling of found element using selenium

I've got a field with a date in it that's identified by a code that's shown in the div previous to it. <div class="fcode"> <div class="fcode_n">(123)</div> ...
0 votes
1 answer
1k views

Problem finding element with text when the text contains &nbsb;

I have the following element in the DOM: <div id="sourceListDiv"> <select id="sourceList" onkeydown="uil.handleKeyDown(this)" size="15" ondblclick=&...
4 votes
2 answers
40k views

how to handle if xpath is same for multiple drop down

I have a situation where i had to handle drop down and click the drop down to select some values. There are two drop down in same page and both has same xpath. The Xpath is giving below. //div[@name=...
1 vote
3 answers
3k 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 ...
2 votes
3 answers
406 views

How to find a specific occurrence of a field that exists in multiple places (Xpath)?

I'm new to Xpath and I wanted to know if there was a way to inspect a specific element, that is repeated multiple times throughout the webpage. For this instance I want to inspect the specific span ...
0 votes
1 answer
2k views

Xpath to an anchor returning error: unable to locate element

I am new to automated testing. I am using C#, Selenium and Chrome 99 with the correct driver. I am trying to get to an anchor tag on the page. Here is my code that is not working, driver.Url = "...
1 vote
3 answers
4k views

Selenium is not finding button even though it has a Class Name and XPath

I am attempting to click a save button but Selenium (with Python) is having issues. I keep getting the error, "Message: no such element: Unable to locate element" Here is the HTML <input ...
2 votes
4 answers
2k views

How to get XPath for the text after the <b> tags

I Need to get XPath for the following, to get the text after the <b> tags <li class="SpacedOut"> <b>Name 6:</b> "ABC" <b>Name 1:</b> "BCD" <b>Name ...
0 votes
2 answers
245 views

I am automating coop website and I'm facing problem while customizing XPath for add to cart button

I have customized an XPath for adding a product which has discount 30% for 2. Now I am facing problem while adding this into the cart. package sample; import java.util.ArrayList; import java.util....
0 votes
1 answer
126 views

Trying to select element from dropdown

After dropdown is expended how can I select an option from the dropdown which is in span image of the expanded dropdown https://prnt.sc/k-rFIUa6Ixeo HTML: <span class="ant-select-selection-...
0 votes
4 answers
375 views

Selenium Locators are not working for this site?

public class LoginPage { WebDriver driver; @FindBy(xpath = "//input[contains(@class,'oxd-input') and @name='username']") private WebElement userName; @FindBy(xpath = "...
0 votes
0 answers
25 views

why my page is not scrolling full at the bottom in selenium testNG(java)?

The images below are my codes(Singleton,homepage and test classes) I'm new to automation and I tried to achieve POM using Singleton now my problem is whenever I try to run my test cases it navigates ...
0 votes
1 answer
103 views

How to capture the element using srcset attribute?

I'm trying to understand the difference between the data-srcset and srcset attributes. I need to get a photo by the srcset attribute, but I can only get it using data-srcset. I don’t really understand ...
0 votes
0 answers
37 views

Can't click on element in selenium

I am trying to click on this element in selenium for login but it wont work for me. This is my code for it driver.FindElement(By.XPath("//div[@id='otherTile']")).Click(); But it wont work. ...
1 vote
2 answers
305 views

Unable to capture the element using xpath

I'm trying to capture the dynamic code using xpath(Selenium+Java). I want to get that code and store it in a variable, but it always returns no such element exception. My xpath looks like below when ...
1 vote
1 answer
23k views

How to write xpath with variable?

I have an xpath: //*[@id='00QE000000gQ9fv_ACTION_COLUMN']/a[2]/span in this xpath 00QE000000gQ9fv is dynamic and _ACTION_COLUMN remains the same. I stored 00QE000000gQ9fv in a String variable as ...
35 votes
6 answers
341k views

A way to match on text using CSS locators

So I use xpath locators and slowly converting to CSS. I haven't found a way to do an exact match based on text. For example converting //a[text()='Log Out']. I know you can do css=a:contains('Log ...
0 votes
1 answer
1k views

Robot Framework how to set a variable in an xpath?

Trying to set a variable in an xpath that I can then replace the text in for a dropdown menu. Not sure if there is a better way to do this I have tried "Replace Variables" also from the ...
0 votes
2 answers
149 views

Selenium : Unable to identify the Xpath of the Grammarly extension in chrome

Unable to get the Xpath for the Grammarly extension which has been added into chrome browser as an extension. In the screen shot below , I am using GMAIL , but you can use any other website like https:...
-1 votes
2 answers
138 views

Google Sheet importxml tr td

wishing to export the values in the red area into google sheets, i can't get the xpath corectly. Thanks a lot Edit: I tried using this, and it s said that is empty "=IMPORTXML(A2,"//div[3]/...
1 vote
3 answers
441 views

Unable to fetch text values present within strong tag using xpath

While trying to print values present within the strong tag using XPath, I'm getting the following exception: org.openqa.selenium.NoSuchElementException: Unable to locate element: strong This is my ...
3 votes
2 answers
65k 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 ...
0 votes
1 answer
2k views

Selenium - cannot click on radio button

I have tried all the possibilities but am unable to click the radio button Yes or No. It would be great if I get some help. I have observed that Need to take this attribute (<span radiogroup class=&...
-1 votes
1 answer
763 views

How to get the correct XPath for a column title using C# and selenium webdriver?

I have the following HTML <label class="ms-Label headerText-269" title="Reference Id">Reference Id</label> which I am trying to locate using XPath. I have written the ...
1 vote
1 answer
3k 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 separate window) ...
3 votes
4 answers
11k views

What do I need to do if dropdown takes more time to populate 1st element from dropdown list?

What do I need to do if drop down take time to populate 1st element from drop down list? Select Cdropdown = new Select(driver.findElement(By.xpath("//select[@id='ClientId']"))); Cdropdown....
0 votes
2 answers
93 views

How to find xpath of "BBB element in following example?

I am unable to find xpath of "BBB" in following span class example. <span class="xyz"> "AAA" "BBB" "CCC" ==$0 </span>
1 vote
0 answers
56 views

Problem facing to automate city auto suggested field when html structure is complex [duplicate]

I have tried many different XPATH, but still I am not able to fetch city from displayed list and perform click on it. I have posted this question earlier also suggested answers couldn't help. With my ...
2 votes
5 answers
1k 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
1 answer
3k views

Cannot find an element with Xpath in Appium

I'm new to Appium. Sorry if the question is duplicated, but I did not find the solution. I have a problem - I cannot locate an element using Xpath, but I have no problems locating it using the ID ...
2 votes
5 answers
2k 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]/...
2 votes
1 answer
12k views

How to get nested web element in dynamic table using xpath

I have a table, which is dynamic (so I can't use strict locator or paths) <tbody> <tr class="odd" role="row"> <td>Company</td> <td class="sorting_1&...

1
2 3 4 5
7