Assert content of cell based on content of a cell in the same row with Cypress - html-table

I just started using Cypress for test automation to see if I like it but I running into a small problem. I want to assert the content of a cell based on a value in another cell in the same row. In the example below the first row contains a user that has finished registering, the cells are all filled. On the second row a new account is visible which has not yet been completed by the user. Cells such as first name and last name are still empty. Display: -
Now I want to verify that the first cell of the row containing 'usermanagementtest#test.com' in the third column contains '-'. There is no way for me to know on what row this will be displayed.
I start by asserting there is a cell visible containing the given email address:
cy.get('.module-user--list tr').find('td').contains('usermanagementtest#lukkien.com').should('be.visible')
but now I would like to assert the value of the first column on that same row.
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
<td>j.doe#test.com</td>
<td>0321654987</td>
</tr>
<tr>
<td>-</td>
<td>-</td>
<td>usermanagementtest#test.com</td>
<td>-</td>
</tr>
</tbody>

With the help of a colleague I achieved this by:
cy.get('.module-user--list tr').find('td').contains('usermanagementtest#test.com').prev().prev().should('contain', '-')
Another way would be to get the parent element and find your way from there:
cy.get('.module-user--list tr').find('td').contains('usermanagementtest#test.com').parent().as('row')
cy.get('#row').find('td:nth-child(1)').should('contain', 'foo')

Related

How do I identify the cell selected in a Quasar table?

How do I identify the cell selected in a Quasar table?
My goal is that once I identify the cell selected, if the user clicks on a custom button, I pass the selected cell information to a pop up page.
Note I'm not using the row selection checkboxes.
we want to be able to select multiple cells from a given column in a quasar table. I believe that this will take a custom selection capability.
You can archive the selection using the data index. Please refer the following codepen for multiple row selection.
https://codepen.io/anon/pen/PrNBpV
And for cell selection refer this.
https://codepen.io/anon/pen/gNrdyL?editors=1010
try this
<q-td key="desc" :props="props" v-for="col in props.cols" :key="col.name" #click.native="selectRow(props.row.__index,col.name)" :class="selected.hasOwnProperty(props.row.__index) && selected[props.row.__index].indexOf(col.name)!=-1?'bg-grey-2':''">
{{ props.row[col.field] }}
</q-td>

Add content on click

in my application i have a simple loop on tr element, to build a table:
<tr v-for="user in users"></tr>
Because i'm using an accordion, i will need two rows (the first row generated with v-for and another row that is the accordion):
<tr></tr> Generated with v-for
<tr></tr> Row for accordion
<tr></tr> Generated with v-for
<tr></tr> Row for accordion
So, v-for iterate the collection and for each row, i have another row (that is the accordion).
I would like build the "additional row" when the user click on the row generated via v-for.
So, how i can "attach" this row below the selected row ? I have think to use slot, but i'm a bit confused...
And, when the user click on another row... the previous attached row should be removed and the next one, will be attached on the selected.
In short, the same behavior of Bootstrap Accordion.
I need this because in this way i can load the accordion content "on demand".
Try wrapping them both around a <template> element as such :
<template v-for="user in users">
<tr></tr> Generated with v-for
<tr></tr> Row for accordion
</template>
The <template> element will not be rendered.

How to store the text of the row which contains the radiobutton 'on'?

I need to automate the store a row's text on selenium IDE. The row is not always the same. The row to be stored is the unique which contains a radiobutton selected.
The path for the button is (where 'x' is an integer variable):
//table[#id='wttrAddressees']/tbody/tr[x]/td[2]/input
I can find the selected button with:
//input[#checked='checked']
or
//input[#checked]
This works, but is not dynamic:
<tr>
<td>storeText</td>
<td>//table[#id='wttrAddressees']/tbody/tr[2]</td>
<td>rowText</td>
</tr>
Is there a way to store the xpath (not a node) of a given webElement?
Thanks,
PS - The test is all in html code.
You can find the target row dynamically by selected radio button as follows :
//table[#id='wttrAddressees']/tbody/tr[td/input[#checked='checked']]
The XPath should return <tr> element where <td> child element has child <input> element checked.

configuring an HTML table

For a school assignment I have to revamp a website. I've been trying to make a table to include an image and buttons beside the image. I have the table set so the image (if you think of this an excel spreadsheet) is in A1, and A1 is as tall as B1, B2, and B3. So I want to have the large cell for the image and 3 cells, or rows rather, beside that to use as buttons.
I can't figure out how to do this, is it possible?
If I'm getting right what you are trying to achieve, I guess you should include rowspan attribute in one of the td tags (A1 cell).
<table border="1">
<tr>
<td rowspan="3">Picture Here</td>
<td>Button1</td>
</tr>
<tr>
<td>Button2</td>
</tr>
<tr>
<td>Button3</td>
</tr>
</table>
Looks like you need to read up on the 'rowspan' attribute for <table>

selenium 1 text box autofill

I'm trying to do autofill for google search
Below is code i tried based on google search results and some blog entries
I'm only posting the code to type in text
selenium.open("/");
selenium.type("q", "banga");
selenium.typeKeys("q", "lore");
selenium.keyDown("q", "\\13");
selenium.waitForCondition("selenium.isTextPresent('bangalore')", "60000");
Any adivce/suggestions for this would be helpful
This code/approach does not autofill the search box
I'm trying it out in IE8
selenium.type("q", "bangalore")
selenium.Click(//div[2]/div/div/table/tbody/tr[2]/td/b) //selects 2nd option from the Autofill dropdown.
For IDE. Insert this html into your source.
<tr>
<td>click</td>
<td>//div[2]/div/div/table/tbody/tr[2]/td/b</td>
<td></td>
</tr>
Try this. It will open the front page, type "bangalore", click Search, then wait:
selenium.open("/");
selenium.type("q", "bangalore");
selenium.clickAndWait("btnG");
selenium.waitForCondition("selenium.isTextPresent('bangalore')", "60000");
Did you try using "select" option to select the value from auto fill?
or using "click" command on element which you want to be select in your search box?