I have an html table wich contain multiple lines.
At the end of each line, the last row contain multiple button. I would like to click on the remove button of the first line.
I tried this Xpath code but the element in not located :
There is a mistake somewhere in my xpath query :
//table[#id='tableTest']/tbody/tr[8]/td[8]/a[#class="remove"]
Your query looks pretty OK, but there is no HTML code so we can just guess what happen. What about the number 8?
Try to use XPath axes. For example locator could look like this:
//table[#id='tableTest']/tbody/tr[1]/descendant::a[#class="remove"]
This should find the remove button in the 1st row whenewer it is.
Click the button of the first line... which I think you mean first row?
//table[#id='tableTest']/tbody/tr//a[#class="remove"]
That SHOULD find the first tr (row) of your table and select the href with the class remove. But it's not going to ensure it's the last cell, which if that's vital you'll need to use something like //table[#id='tableTest']/tbody/tr/td[last()]/a[#class="remove"]
Also, if you attach the html snippet this becomes much easier for many of us to answer.
Related
I have a list with several rows and columns. Each row has a button called "Show Trail Details".
During the test, i click twice on the "Date" column title, to have the latest entry in the list in the first row.
I need to get the ID of the button inside the first row.
The IDs are changing all the time. So its either:
//tbody/tr[1]/td[6]/button[1]/span[1] or //tbody/tr[1]/td[4]/button[1]/span[1] and so on.
I tried to copy the HTML, but it looks weird when i run the html code.
The inspect looks like this:
Is there any way how to get that ID?
Thanks!
I need to get the ID of the button inside the first row.
But there's no "id" attribute on either the td, button, or span elements?
Or do you mean the '_b1_685ddfc4-de...' attribute?
If the id is just a means of getting access to the first button then you could just use something like:
WebElement firstShowTrailDetailsButton = driver.findElements(By.cssSelector("td[style='text-align:right'] button.mud-button")).get(0);
I am trying to automate the web table on the demoqa site https://demoqa.com/webtables where I am aiming to click the edit and delete button for a specific user. Please find the attached screenshot for reference.
Screenshot
I am trying to click the edit and delete button for the user 'Cierra' hence I have created the customize XPath '//div[contains(text(),'cierra#example.com')]//following::div[text()='Insurance']//following::div//div//span[#title='Edit']'
Trying to click the edit and delete button using the contains text with email 'cierra#example.com' however I see four results even I use the unique username. Could anyone help me with this?
(//div[contains(text(),'cierra#example.com')]//following::div[text()='Insurance']//following::div//div//span[#title='Edit'])[1]
you can enclose the result in bracket and call [1] , to get first one:
But you don't have to over complicate it , just get email then go back to parent and get span under that parent ,:
//div[contains(text(),'cierra#example.com')]/..//span[#title="Edit"]
if you still want to use fancy xpath locator then use :
//div[contains(text(),'cierra#example.com')]/following-sibling::div[contains(text(),'Insurance')]/following-sibling::div//span[#title='Edit']
i'm struggling with this one, i need to hide a button, i mean a command button based on the value of a column.
i grab the following example from kendo pages, i would like to show/hide the button "View Details" based on the "Discontinued" value.
i've already tested with :visible or :hide properties without success.
https://stackblitz.com/edit/e1fre3
does someone know how to get this working?
The command option is expecting string or array so this is an updated stackblitz example that worked at my side - https://stackblitz.com/edit/e1fre3-wnzfer?file=index.html
I am exactly in the line where there is the text ='Ver Informe'.
I want to go to the button that is next to that line.
Because only work when I make the click there.
Could you help me go there?
I tried: /button1 -- and doesn't work.
I need to see more of the surrounding html but if I understand your question correctly you want the button that contains the element with the text 'Ver informe'.
Try this:
//div[4]//article[1]//descendant::button[#type='button' and ./*[contains(text(),'Ver informe')]]
basically the span is wrapped in the button tag. So you can use the below xpath.
//span[normalize-space(.)='Ver informe']/parent::button
I am trying to make the table component with the button inside the table column in CDE Pentaho. How can it be achieved?
I guess it will need some work.
In the Draw function of your table, you may put some javascript to manipulate the DOM and add your button : as far as I remember, the draw function receives a parameter that is a structure with the column and row index of the current cell.
Try first this code in the draw function :
function(paramdraw) {
console.log(paramdraw);
}
and look for the content of paramdraw iin the console.
Maybe there is a better way to do it...
What we do here usually is something like editing the query on the datasource with a column that output the HTML code for a button.
SELECT
ID,
NAME,
concat('<input type="button" onclick="alert(',ID,')">click me</input>') as button
FROM
foo
WHERE
bar='bar';
That should display a button. If you are not using a query as datasource, but a transformation the idea is the same. Just make the output contains a string that when interpreted by the browser is a button.
Hope it helps. =)