Selenium IDE not recording anything - selenium

Below is the pagesource, Selenium IDE is not recording anything. Also, when I try to click the "TabBar:AccountTab_arrow" using xpath, it does not click on the arrow rather it click on the tab. There is a menu that gets displayed on click event of the arrow.
*<div id="mainTable" class="screen">
<div id="topDivision" style="height:100%">
<table class="contentTable" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td class="page_header">
<div id="page_header" class="page_header">
<img id="logo" src="images/logo.gif">
<div id="helpLogoutLinks">
<div id="topModetabs" class="modetabs">
<div id="QuickJump_container" class="navigator">
<span id="topModetabs_left" class="modetabs_left"></span>
<span id="topModetabs_middle" style="width: 3px;">
<div class="off" onmouseleave="if(window.DHTML) {DHTML.buttonLeave(this)}" onmouseenter="if(window.DHTML) {DHTML.buttonEnter(this)}">
<div class="off" onmouseleave="if(window.DHTML) {DHTML.buttonLeave(this)}" onmouseenter="if(window.DHTML) {DHTML.buttonEnter(this)}" classname="">
<span id="TabBar:AccountTab_left" class="tab_left_off"> </span>
<span id="TabBar:AccountTab_container" class="tab_middle_off">
<span class="menu_tab_off_left"></span>
<span id="menu_TabBar:AccountTab" class="menu_tab_off" onclick="event.cancelBubble = true;" onmouseover="MenuImpl_mouseOverMenu('TabBar:AccountTab')">
<a id="TabBar:AccountTab" class="menu_link_tab_off" href="javascript:void(0)" onclick="Recorder.click(this);;Events.invokeEvent('TabBar:AccountTab_act', true);event.cancelBubble=true" onfocus="null">Account</a>
<a id="TabBar:AccountTab_arrow" onclick="MenuImpl_showMenu('TabBar:AccountTab')">
<span class="menu_arrow_tab_off" border="0"></span>
</a>*

This might be because the elements you're trying to interact with, are within iframe. Selenium IDE doesn't record actions that are performed withing iframe.This is known issue, please go here

Related

xpath with Multiple condition in Selenium

Wants to locate element with multiple condition on particular row,
I want to Click on div which contains ng-click="condition001" which has parent link contains Auto-001
So query become like : Select element xpath("//div[contains(#ng-click,'condition001')]") where Link("Auto-001")
<tr ng-repeat="(abc, xyz)" ng-show="data.length > 0">
<td class="x001">
<div class="x002">
<a class="x003" href="#">Auto-001</a>
</div>
</td>
<td class="x004">
<div class="x005">
<div class="x006">
<div class="x007" ng-click="condition001" tabindex="0">
<i class="x008"></i>
</div>
</div>
</div>
</td>
</tr>
Please suggest relevant xpath code which can work for above criteria,
To click on the WebElement identified through xpath as ("//div[contains(#ng-click,'condition001')]") where it has partialLinkText as ("Auto-001") you can use the following line of Java code :
WebElement myElem = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//a[#class='x003' and contains(.,'Auto-001')]//following::td[1]//div[#class='x007' and #ng-click='condition001']")));

xpath with following-sibling

I want to access the table with classname 'table table-hover' that should be under the class=='box-title' that contains the text 'OODR Items for next 20 Days'. Can any one please help me out to get the xpath for this ? I tried with following-sibling but no luck. Thanks in advance.
<?xml version="1.0" encoding="UTF-8"?>
<div id="topTenSellers" class="box box-solid box-primary frontpageWidget">
<div class="box-header">
<i class="fa fa-group" />
<h3 class="box-title">OODR Items for next 20 Days</h3>
<div class="box-tools pull-right">
<button class="btn btn-primary btn-sm" data-widget="collapse">
<i class="fa fa-minus" />
</button>
</div>
</div>
<!-- /.box-header -->
<div class="box-body no-padding">
<table class="table table-hover">
<tbody>
<tr>
<th style="width: 10px">#</th>
<th>Booking</th>
<th>Item Start Date</th>
<th>Site</th>
<th>Supplier</th>
</tr>
<tr>
<td>
<strong>1</strong>
</td>
<td>
(642143)
</td>
<td>21/10/2017 00:00:00</td>
<td>Ski</td>
<td>OODR - Out of Date Range</td>
</tr>
</tbody>
</table>
</div>
<!-- /.box-body -->
</div>
You can try following instead of following-sibling as mentioned h3 and table nodes are not siblings:
//div[#id="topTenSellers"]//h3[#class="box-title" and .="OODR Items for next 20 Days"]/following::table[#class="table table-hover"]
If there is only one element of that class name then either of these will work. One thing to note though, selenium can struggle with spaces in class names depending on the version and browser. If you find that is the case, then use multiple contains to handle the spaces.
//table[contains(#class,'table table-hover')]
//table[#class = 'table table-hover']
If you need that the element as a child of that OODR Items for the next 20 days
//h3[contains(text(),'OODR Items for the next 20 days')]/parent::div/following-sibling::div/table[#class ='table table-hover']
This path uses your anchor point, "OODR Items..", then goes to the parent, then sibling, then to the item with the specified class name. Good luck!

Action at a paragraph field doesn't work with type command in IDE

Want to find the CSS locator to add the input in the paragraph.
<div class="fr-element fr-view" style="min-height: 400px;" dir="auto" spellcheck="true" contenteditable="true">
<p style="">
</div>
The css would be
css=.fr-view.fr-element p
You can manipulate this using javascript within the IDE:
<tr>
<td>runScript</td>
<td>document.querySelectorAll('.fr-view.fr-element p')[0].innerHTML='Some New Text'</td>
<td></td>
</tr>

Selenium WebDrivers -Not able to select dynamic check box which has no name

<div id="checkboxfield-3844" class="x-field x-form-item x-field-default x-form-cb-checked x-form-dirty" style="width: 492px;">
<label id="checkboxfield-3844-labelEl" class="x-form-item-label x-form-item-label-left" style="margin-right:5px;width:200px;" for="ext-gen6460">Is Stitching Point:</label>
<div id="checkboxfield-3844-bodyEl" class="x-form-item-body x-form-cb-wrap" role="presentation" style="width: 287px;">
<input id="ext-gen6460" class="x-form-field x-form-checkbox" type="button" hidefocus="true" autocomplete="off" aria-checked="true" aria-invalid="false" role="checkbox" aria-describedby="checkboxfield-3844-errorEl" style="-moz-user-select: text;" data-errorqtip="">
</div>
<div id="checkboxfield-3844-errorEl" class="x-form-error-msg" style="display:none"></div>
<div class="x-clear" role="presentation"></div>
</div>
This is my Div , out of it iam not able to select the checkbox since there is no name .Need some help on this
Assuming there is only one 'label tag' with innerHTML/text as "Is Stiching Point:", the below xpath will point to the checkbox:-
driver.findElement(By.xpath("//label[.='Is Stitching Point:']/..//input[#role='checkbox']")).click();
NOTE: Above is a java code. In case you are using a different language binding, you can refer this to employ the same thing.
Edit
Below is the alternative way using JavascriptExecutor:
WebElement element = driver.findElement(By.xpath("//label[.='Is Stitching Point:']/..//input[#role='checkbox']"));
((JavascriptExecutor)driver).executeScript("arguments[0].click();", element);

Need unique field to identify using Selenium WebDriver

I need to find the the unique field to identify the search box and enter text in it.
<style type="text/css">
</head>
<body style="min-height: 81px;">
<div class="shared-page" data-cid="view221" data-view="views/shared/Page" data-render-time="0.02">
<a class="navSkip" tabindex="1" href="#navSkip">Screen reader users, click here to skip the navigation bar</a>
<header role="banner">
<a id="navSkip"></a>
<div class="main-section-body" role="main">
<div class="timeline" data-cid="view4947" data-view="views/timeline/Master" data-render-time="0.107">
<div class="section-padded section-header">
<div class="timeline-title" data-cid="view5085" data-view="views/timeline/Title" data-render-time="0.001">
<div class="search-bar-wrapper shared-searchbar" data-cid="view4948" data-view="views/shared/searchbar/Master" data-render-time="0.104">
<form class="search-form" action="" method="get">
<table class="search-bar search-bar-primary">
<tbody>
<tr>
<td class="search-input" width="100%">
<div id="search" class="shared-searchbar-input" data-cid="view4949" data-view="views/shared/searchbar/Input" data-render-time="0.002">
<div class="search-field-background"> </div>
<div class="search-field-wrapper">
<label class="placeholder-text" for="397271.5897375417" style="display: block;">enter search here...</label>
<textarea id="397271.5897375417" class="search-field" autocapitalize="off" autocorrect="off" spellcheck="false" name="q" rows="1"></textarea>
textarea is the field related to the search box. I tried using class, name but it says unable to locate element, the numeric id too is dynamic. Please let me know what to use in this case.
It should be possible to find this element by class name
in ruby:
driver.find_element(:class, "search-field")
or in java:
driver.findElement(By.className("search-field"));
Following xpath should work:
//div[#id='search']//textarea[#class='search-field']
If the <textarea> is only one, you can search with
driver.findElement(By.tagName("textarea"));
Use xpath,
driver.findElement(By.xpath("//textarea[#class='search-field']"));
Or
driver.findElement(By.name("q"));