Selenium mouseOver images at child nodes using DynaTree - selenium

Thanks for taking the time to ready my questions. I need to mouseover then mousedown on an image (cog.png) for a specific node child represented by text to the right of an image. I can successfully Target the class but cannot work out how to target the image alone.
HTML, I want to target the cog.png near 'Australia'
<div id="tree" class="">
<ul class="dynatree-container dynatree-no-connector">
<li class="dynatree-lastsib">
<span class="dynatree-node dynatree-expanded dynatree-has-children dynatree-lastsib dynatree-exp-el dynatree-ico-e"></span>
<ul style="">
<li class="">
<span class="dynatree-node dynatree-exp-c dynatree-ico-c" style="background-color: transparent;">
<span class="dynatree-connector"></span>
<img alt="" src="/icn/cog.png"></img>
<a class="dynatree-title" title="This option is Active" href="#">
Australia
</a>
</span>
Target code for Selenium IDE (which targets the full span, I just want the image cog.png)
//span[contains(#class,'dynatree-node') and //img[#src='/icn/cog.png'] and .//text()='Australia']
I tried
//img[#src='/icn/cog.png']
Not surprisingly it was not specific enough and targeted the first instance of the image
Versions
Firefox 32.0.3
Selenium IDE: 2.7.0

This is the code that I used to navigate on the dynatree, it wsa made more difficult as the first item was added as a child, the remainder added below or above the child. I kept track by creating 'counts' to determine at what point the items were added.
<tr>
<td>waitForTextPresent</td>
<td>Australia</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//span/a[contains(., '${LocationLevel1Ext}')]/preceding::span[#class='dynatree-expander'] [1]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//span/a[contains(., '${LocationLevel2Ext}')]/preceding::span[#class='dynatree-expander'] [1]</td>
<td></td>
</tr>
<tr>
<td>clickAt</td>
<td>//span/a[contains(., '${PreviousLocationName}')]/preceding::img[#src='/icn/cog.png'] [1]</td>
<td></td>
</tr>
<tr>
<td>waitForTextPresent</td>
<td>Add before this node</td>
<td></td>
</tr>
<tr>
<td>mouseOver</td>
<td>//span[contains(text(), 'Add before this node')]</td>
<td></td>
</tr>
<tr>
<td>mouseDown</td>
<td>//span[contains(text(), 'Add before this node')]</td>
<td></td>
</tr>

Related

How to indent kit component items on Advanced PDF packing slip

I am setting up a customized packing slip form via Advanced PDFs in NetSuite and need help fulfilling a certain formatting request. I am having trouble with the placement of the code to indent only kit items and not their components. NetSuite will not accept my changes on the form due to the misplacement of #list and #if tags. If someone could assist clearing this issue up for me by showing an example of what that should look like, it would be most appreciated. Let me know if more information is needed here and thanks! -Ryan I have tried placing the code before and after the #list tag.
<table class="itemtable" style="width: 100%; margin-top: 10px;">
<thead>
<tr>
<th colspan="12">${salesorder.item[0].item#label}</th>
<th align="right" colspan="4">${salesorder.item[0].quantityordered#label}</th>
<th align="right" colspan="4">${salesorder.item[0].quantityremaining#label}</th>
<th align="right" colspan="4">${salesorder.item[0].quantity#label}</th>
</tr>
</thead>
<#list salesorder.item as tranline> //callout to list items from item fulfillment
<#if tranline.custcol_9r_noncomponent='T'> //checks to see if items are kits items or not
<#if tranline.custcolitemtype="Kit/Package"><tr style="font-weight:bold"> //bolds kit items
<#else><tr style="font-weight:normal"> //if not kit item, uses normal formatting
</#if> //for kit items use this formatting
<td width="15%" class="item" font-size="7pt">${tranline.item}</td>
<td width="20%" class="item">${tranline.description}</td>
<td width="8%" class="item" align="center">${tranline.quantityremaining}</td>
<td width="8%" class="item" align="center">${tranline.quantity}</td>
<td width="8%" class="item"> </td>
<td width="9%" class="item"> </td>
</tr>
<#else> //for component items, use this formatting
<tr>
<td width="15%" class="kititem" font-size="7pt"> ${tranline.item}</td>
<td width="20%" class="kititem">${tranline.description}</td>
<td width="8%" class="kititem" align="center">${tranline.quantityremaining}</td>
<td width="8%" class="kititem" align="center">${tranline.quantity}</td>
<td width="8%" class="kititem"> </td>
<td width="9%" class="kititem"> </td>
</tr>
</#if> //should refer to tranline.custcol_9r_noncomponent='T'statement
</#list> //should close the callout for list items
</table> //ends table

While printing report content divide on two pages

When I print the report it cut the content on two page. I want if the content increases then with regards come in next page.
<tr>
<td style="padding-bottom:10px;">Terms & Conditions</td>
</tr>
<tr>
<td style="padding-left:20px;">
<span t-if="doc.comment">
<t t-set="comment" t-value="doc.comment.split('\n')"/>
<ol>
<t t-foreach="comment" t-as="pt">
<li><span t-esc="pt"/></li>
</t>
</ol>
</span>
</td>
</tr>
<tr>
<td style="padding-top:10px;page-break-inside:avoid;">With regards</td>
</tr>
<tr>
<td style="padding-top: 120px;page-break-inside:avoid;">.........................................</td>
</tr>
<tr>
<td>Mandy Tsang</td>
</tr>
<tr>
<td>Director</td>
</tr>
</table>
Here, I attach the file what currently print.enter image description here
enter image description here
I want with regards come in next page
If you are sure that you wanna add a page break before With regards you should split your table before that part into 2 tables and add and style="page-break-before:always;" to instruct report engine to make a page break before the desired content.

Selenium IDE selecting from the list which is powered by Google

I'm new to Selenium IDE and I need to run some test on one website. Everything seems to work just fine except the part where I need to select my location since that list is powered by Google I can't really get the object by list id..
Here's my test so far:
<tr>
<td>open</td>
<td>/</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=newregister-form-email</td>
<td>javascript{"test+" + Math.floor(Math.random()*11111) + "#gmail.com";}</td>
</tr>
<tr>
<td>type</td>
<td>id=newregister-form-pass</td>
<td>test</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>css=input.submitLogin</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad(1000)</td>
<td></td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=u_users-form-name</td>
<td>Tester</td>
</tr>
<tr>
<td>type</td>
<td>id=u_users-form-surname</td>
<td>Test</td>
</tr>
<tr>
<td>type</td>
<td>id=u_users-form-phone</td>
<td>javascript{"+3706" + Math.floor(Math.random()*11111);}</td>
</tr>
<tr>
<td>type</td>
<td>id=cityinput</td>
<td>Vilnius</td>
</tr>
<tr>
<td>pause</td>
<td>1000</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=cityinput</td>
<td>Vilnius</td>
</tr>
The last part is where I need to choose from the dropdown list but Selenium IDE doesn't see it when recording.
Thank you in advance
Update:
This is html code of the city input :
<div class="row field">
<div class="col-xs-12 col-sm-8 col-sm-offset-4 col-md-offset-3 formelement-wrapper">
<input type="text" id="u_users-form-country" name="u_users-form[country]" value="" />
</div>
</div>
<div class="row field">
<div class="col-xs-12 col-sm-8 col-sm-offset-4 col-md-offset-3 formelement-wrapper">
<input type="text" id="u_users-form-city" name="u_users-form[city]" value="" />
</div>
</div>
<div class="row field">
<div class="col-xs-12 col-sm-8 col-sm-offset-4 col-md-offset-3 formelement-wrapper">
<input type="text" id='cityinput' placeholder="Miestas, Ε alis">
</div>
</div>
instead of a pause you should use a waitForElementPresent on id=cityinput. This will allow you to wait until that element is present and not just 1 second (as your pause is currently doing)
<tr>
<td>waitForElementPresent</td>
<td>id=cityinput</td>
<td></td>
</tr>

Unable to locate element using xpath

Am very new to Selenium just learnt few things and trying to automate.Unable to locate an element in Selenium webdriver for the below one:
<div class="navBg withSubMenu">
<table id="topnav" class="navTable" cellspacing="0" cellpadding="0" style="-moz-user-select: none; cursor: default;">
<tbody>
<tr>
<td class="logoCell navCell" valign="top">
<td class="navItem navCell relative selected">
<td class="navItem navCell relative notSelected">
<a class="content tasks" href="/tasks/otasklist.do">
<div class="label" style="z-index:155; ">TASKS</div>
<div class="img"> </div>
</a>
</td>
<td class="navItem navCell relative notSelected">
<a class="content reports" href="/reports/reports.do">
</td>
<td class="navItem navCell relative notSelected">
<td class="menuCell navCell" valign="top">
</tr>
<tr class="secondLevelRow">
</tbody>
</table>
I have written code like
driver1.findElement(By.xpath("//*[Contains(#class,'content tasks')]")).click();
Anyone please help me.
And also please suggest some sites or links to learn more about locators especially xpath. I tried few but not getting it in depth.
Thanks in advance.
Start contains with a lower case c:
driver1.findElement(By.xpath("//*[contains(#class, 'content tasks')]")).click();
<a class="content tasks" href="/tasks/otasklist.do">
driver1.findElement(By.xpath("//a[#class='content tasks']")).click();

Select Kendo Dropdown with Selenium IDE

I am using the Selenium IDE and I cannot select an item from the kendo dropdown menu that I want. Does anybody know how to do this with the Selenium IDE? (or else in C# but I wouldn't be able to test that for a while).
Here's a website that has a dropdown that I was trying to practice on, by trying to assert some of the other dropdown options, no luck. http://derp-bear.herokuapp.com/ui_widgets/kendo_ui_example
<tr>
<td>open</td>
<td>http://derp-bear.herokuapp.com/ui_widgets/kendo_ui_example</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=span.k-input</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>css=span.k-input</td>
<td>XL - 7 5/8</td>
</tr>
Any help would be great!
This is not a traditional select drop down. So the dropdown and the options are in 2 different places.
Drop down arrow is located in the below code
<span class="k-select" unselectable="on">
<span class="k-icon k-i-arrow-s" unselectable="on">select</span>
</span>
Drop down arrow can be selected with the css
css=span.k-select
Drop down options are located in the below location. This section is activated after clicking on the drop down arrow.
<ul class="k-list k-reset" unselectable="on" style="overflow: auto;" tabindex="-1" role="listbox" aria-hidden="true" id="size_listbox" aria-live="off">
<li class="k-item" unselectable="on" role="option" tabindex="-1">S - 6 3/4</li>
<li class="k-item" unselectable="on" role="option" tabindex="-1">M - 7 1/4</li>
<li class="k-item k-state-selected k-state-focused" unselectable="on" role="option" tabindex="-1" id="size_option_selected" aria-selected="true">L - 7 1/8</li>
<li class="k-item" unselectable="on" role="option" tabindex="-1">XL - 7 5/8</li>
</ul>
Any of the 4 drop down options can be selected with the xpath
xpath=//li[#class='k-item'][.='L - 7 1/8']
Selenium IDE code will be as follows:
<tr>
<td>open</td>
<td>/ui_widgets/kendo_ui_example</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=span.k-select</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>3000</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>xpath=//li[#class='k-item'][.='XL - 7 5/8']</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>3000</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>css=span.k-input</td>
<td>XL - 7 5/8</td>
</tr>
Use pause to wait for stuff to load.