I am trying to write a selenium test for a drag and drop operation.
I am dropping in a tr but I need to specify whereabouts on the row as the tr itself covers 5 slots (this is for a calendar app) but the slots are not td's so I think the app might be using some sort of x,y co-ordinates within the tr.
Specifically the tr that goes all the way across is
<tr class="fc-slot15 fc-minor">
<th class="fc-agenda-axis fc-widget-header"></th>
<td class="fc-widget-content">
<div style="position:relative"></div>
</td>
</tr>
So far the best xpath I have is xpath=(//table//tr[contains(#class,'fc-slot15')]//td) but this identifies the whole tr.
Visually it looks like this:
I'm trying to do it for full-calendar but how to drop in a specified place seems general enough.
Could I do it with mouse down, mouse move(x,y), mouse up perhaps?
Related
I failed to allocate following element via selenide (i need find and fill it with text (ID) :
<tr>
<th class="col-md-3 basicPropertiesName">Id</th>
<td class="col-md-9">
<input class="form-control ng-pristine ng-valid ng- touched" ng-keypress="keypressHandler($event, 2)" ng-model="newInsight.id" placeholder="ID">
</td>
</tr>
Or maybe this?
$("input[ng-model='newInsight.id']").setValue(value);
Maybe you need something like this?
By(xpath("//input[#ng-model='newInsight.id']))
$(By.xPath("//tr[./th[text()='Id']]")).find("input").setValue("some text)
or without additional find()
$(By.xPath("//tr[./th[text()='Id']]//input")).setValue("some text)
You could use following options using css selectors also.
String str="th[class*='basicPropertiesName']";
SelenideElement element =$(str);
or
String str="th:contains('Id')";
SelenideElement element =$(str);
one important moment.. all from above would fail if your example is placed in iframe (i've faced with such issue last week).
required actions:
a) how to find out if <tr> is (or not) part of iframe >> locate your tr on page, right-click on it, and ensure that you have no View frame source
example of page Inspect with iframe
if No such - try examples from above...
if There is one - see below
b) how to switch into iframe
you have to findout frame name...
--- make r-click on object + Inspert
--- locate your <tr>
--- click on it into Inspect
--- in the bottom of Inspert you'd see whole tree till selected element
--- move to the top of tree and you'd see something like iframe#framenamehere
--- copy it
before seaching your element add line like:
WebDriverRunner.getWebDriver().switchTo().frame(here the value from
prev. steps without #);
and search for your <tr>
I suggest that you use the th text in your query, to better target the input element:
Selenide.$(Selectors.byXpath("//th[text()='Id']/following-sibling::td/input"));
Note: Better to assign a unique id to the input element (and to every element under test) to improve readability and maintenance of your code.
I've got a large number of <asp:RequiredFieldValidator> server controls that I want to delete from multiple webforms pages. It's too tedious to remove them all by hand.
How can I create a regex to use in Visual Studio's Find and Replace dialog?
I'd like to remove the server control entirely. In the example below, it'd leave an empty table cell.
Currently
<td>
<asp:RequiredFieldValidator attr1=""></asp:RequiredFieldValidator>
</td>
Leaving only (whitespace not necessary to remove):
<td></td>
So let's say my structure looks like this at some point:
..........
<td>
[...]
<input value="abcabc">
[...]
</td>
[...]
<td></td>
[...]
<td>
<input id="booboobooboo01">
<div></div> <=======I want to click this!
</td>
.........
I need to click that div, but I need to be sure it's on the same line as the td containing the input with value="abcabc". I also know that the div I need to click (which doesn't have id or any other relevant attribute I can use) is in a td at the same level as the first td, right after the input with id CONTAINING "boo" (dynamically generated, I only know the root part of the id). td's contain nothing relevant I can use.
This is what I tried as far as xpath goes:
//input[#value='abcabc']/../td/input[contains(#id,'boo')]/following-sibling::div
//input[#value='abcabc']/..//td/input[contains(#id,'boo')]/following-sibling::div
None of them worked, of course (element cannot be found).
I want to know if there's a way of selecting that div and how.
EDIT: //input[#value='abcabc']/../../td/input[contains(#id,'boo')]/following-sibling::div is the correct way. This was suggested by the person with the accepted answer. Also note that he offered a slightly different way of doing it. See his answer for details.
Try
//input[#value='abcabc']/ancestor::tr[1]/td/input[contains(#id,'boo')]/following-sibling::div[1]
Note that //input[#value='abcabc']/.. only goes up to the parent <td>, that's why your's did not work.
Another XPath that may work, is a bit more simple:
//input[#id='booboobooboo01']/../div[1]
I've been using Selenium IDE and getting some good results. I've done a lot of reading about following-sibling and preceding-sibling but I can't locate the right radio button.
Essentially I want to find the row in a table with the word 'testing' and then click the radio button in the cell.
So far I can find the input button
//input[#type='radio']
and find the text testing
//a[contains(text(),'testing')]
I've been trying to use this in the ide
check | //input[#type='radio']/following-sibling::td[1]/a[contains(text(),'testing')]
but I get the error [error] locator not found: //input[#type='radio']/following-sibling::a[contains(text()[1],'testing')]
Any help to change this is really appreciated :)
Cheers
Damien
here's the bare basic table ...
<tbody id="list">
<tr>
<th>
<label class="radio">
<input class="presentation_radio" type="radio" value="1" name="presentation_radio">
</label>
</th>
<td>
testing
</td>
<td>testing</td>
<td>Joe Acme</td>
<td>Presentation</td>
<td>03 May 2012</td>
<td>5 (1)</td>
</tr>
</tbody>
The problem with your xpath is that td and input are not sibling (they don't have common parent) and even if you change your xpath to more correct version:
//input[#type='radio']/following::td[1]/a[contains(text(),'testing')]
it will find a that have preceding checkbox instead of checkbox itself. So correct xpath will be:
//a[contains(text(),'testing')]/preceding::input[#type='radio'][1]
or
//tr[descendant::a[contains(.,'testing')]]//input[#type='radio']
For xpath axis tutorial read this: http://msdn.microsoft.com/en-us/library/ms256456.aspx
I am using Watin with Cucumber and Specflow to automate the testing of a web application using a jquery table.
I want to find a specific data in the table, but i don't know how to access the table. When I find the data i am looking for, i want to return the id of the row to pass it to an URL that navigate to the Delete page so I can delete the data.
This is my code in the page:
<tr id="S-1-5-21-373314506-2757628719-1954316189-3686" class="ui-widget-content jqgrow ui-row-ltr" role="row" tabindex="-1">
<td class="ui-state-default jqgrid-rownum" aria-describedby="list_rn" title="2" style="text-align:center;" role="gridcell">2</td>
<td aria-describedby="list_Actions" title="Edit | Details | Delete" style="" role="gridcell">
Edit
|
Details
|
Delete
Ivana Bagur
So, in this example, I want to go through my table and when i find Ivana Bagur, return the tr id attribute so then I can pass this id attribute to effectively delete the element.
Can anyone give me an idea how to go through the table until i find the data and then capture the tr id?
First, something is off in the code you posted as it is not showing entirely correctly; somehow you got actual links to display starting at 'details' rather than your code.
To find the TR ID....general idea:
Find the element containing Ivana Bagur
Find the ancestor of that element that is a TR.
If Ivana is just text in a tablcell it might look like:
string IvanaRowID = ((TableRow)(myIE.Table(myID).tablecell(Find.ByText(myRegexContainingIvanaBagur)).Ancestor("tr"))).Id;
It has been a while since I've done this, and my casting might be a bit off / non-optimal, but the general idea is there.