Select drop down value using selenium RC - selenium

There is a drop down with 2 values enabled and disabled, but the field has type=button.
I am not sure how to select values in this drop down.
Below is the html code for the element
<button id="loggingTargetStatus" class="dijitReset dijitStretch dijitButtonContents dijitDownArrowButton" waistate="haspopup-true,labelledby-loggingTargetStatus_label" wairole="button" dojoattachpoint="focusNode,titleNode,_arrowWrapperNode" value="" type="button" role="button" aria-haspopup="true" aria-labelledby="loggingTargetStatus_label" tabindex="0" style="-moz-user-select: none;">
<span class="dijitReset dijitInline cpmIconStateEnable" dojoattachpoint="iconNode"></span>
<span id="loggingTargetStatus_label" class="dijitReset dijitInline dijitButtonText" dojoattachpoint="containerNode,_popupStateNode">Enabled</span>
<span class="dijitReset dijitInline dijitArrowButtonInner"> </span>
<span class="dijitReset dijitInline dijitArrowButtonChar">▼</span>
</button>
Please suggest how to select using selenium RC

It is not a select element, and so you cannot interact with it as such. It probably uses AJAX to make it look like a select menu.
You will need to click() on all the appropriate elements. It has been years since I have used selenium-rc, so the below code will probably need to be adjusted.
selenium.click("loggingTargetStatus"); // to enable the menu
selenium.click(your_field); // you will have to find the correct locator

Related

unique xpath combined two attributes

Ho do I make unique xpath to let the robot locate into second field?
i used this but failed:
Click //div[contains(#class,'ant-select SearchPrompter_advInput__3P9Jf ant-select-multiple ant-select-allow-clear ant-select-show-search') and contains(text(),'Select Source(s)')]
First Field:
<div class="ant-select SearchPrompter_advInput__3P9Jf ant-select-multiple ant-select-allow-clear ant-select-show-search">
<div class="ant-select-selector">
<div class="ant-select-selection-overflow">
<div class="ant-select-selection-overflow-item ant-select-selection-overflow-item-suffix" style="opacity: 1;">
<div class="ant-select-selection-search" style="width: 3px;">
<input autocomplete="off" type="search" class="ant-select-selection-search-input" role="combobox" aria-haspopup="listbox" aria-owns="rc_select_9_list" aria-autocomplete="list" aria-controls="rc_select_9_list" aria-activedescendant="rc_select_9_list_7" value="" id="rc_select_9" style="opacity: 0;" aria-expanded="false" readonly="" unselectable="on">
<span class="ant-select-selection-search-mirror" aria-hidden="true"> </span>
</div>
</div>
</div>
<span class="ant-select-selection-placeholder">attribute(s)</span>
</div>
</div>
second field:
<div class="ant-select SearchPrompter_advInput__3P9Jf ant-select-multiple ant-select-allow-clear ant-select-show-search">
<div class="ant-select-selector">
<div class="ant-select-selection-overflow">
<div class="ant-select-selection-overflow-item ant-select-selection-overflow-item-suffix" style="opacity: 1;">
<div class="ant-select-selection-search" style="width: 3px;">
<input autocomplete="off" type="search" class="ant-select-selection-search-input" role="combobox" aria-haspopup="listbox" aria-owns="rc_select_10_list" aria-autocomplete="list" aria-controls="rc_select_10_list" aria-activedescendant="rc_select_10_list_0" value="" id="rc_select_10" style="opacity: 0;" aria-expanded="false" readonly="" unselectable="on">
<span class="ant-select-selection-search-mirror" aria-hidden="true"> </span>
</div>
</div>
</div>
<span class="ant-select-selection-placeholder">Select Source(s)</span>
</div>
</div>
this xpath works (when I test at chrome developer console, it is detected) but when robot executed the script, it does not really click into the field. the drop-down list does not display.
Click //div[#class="ant-select SearchPrompter_advInput__3P9Jf ant-select-multiple ant-select-allow-clear ant-select-show-search"]
error:
FAIL
Message: TimeoutError: locator.click: Timeout 10000ms exceeded.
=========================== logs ===========================
waiting for selector "//span[contains(#class,'ant-select-selection-placeholder') and contains(text(),'Select Source(s)')] >> nth=0"
selector resolved to hidden <span class="ant-select-selection-placeholder">Select Source(s)</span>
attempting click action
waiting for element to be visible, enabled and stable
element is not stable - waiting...
element is visible, enabled and stable
scrolling into view if needed
done scrolling
checking that element receives pointer events at (1080.4,304.7)
<div class="ant-select-selection-overflow">…</div> intercepts pointer events
retrying click action, attempt #1
waiting for element to be visible, enabled and stable
element is visible, enabled and stable
scrolling into view if needed
done scrolling
checking that element receives pointer events at (1080.4,304.7)
[ Message content over the limit has been removed. ]
element is visible, enabled and stable
scrolling into view if needed
done scrolling
checking that element receives pointer events at (1080.4,304.7)
<div class="ant-select-selection-overflow">…</div> intercepts pointer events
you are not so far from solution to select the uniq div
text equals:
//div[contains(#class,'ant-select SearchPrompter_advInput__3P9Jf ant-select-multiple ant-select-allow-clear ant-select-show-search') and .//span[text()='Select Source(s)']]
if you want the expression contains:
//div[contains(#class,'ant-select SearchPrompter_advInput__3P9Jf ant-select-multiple ant-select-allow-clear ant-select-show-search') and .//span[contains(.,'Select Source(s)')]]
You can give an index according to your best match like
(//*[#class='ant-select SearchPrompter_advInput__3P9Jf ant-select-multiple ant-select-allow-clear ant-select-show-search'])[2]
Try to use the span tag and parent keyword in the xpath to find the required div tag element.
As per the HTML Code, Xpath would be something like this.
//span[contains(text(),'Select Source')]/parent::div/parent::div/parent::div

How can I find the dynamic xpath for the word "Pace" in the attached?

I need the dynamic xpath for the the word "Pace" in the below code It is the the name of the third column in a table.
I have tried the following:
//table[contains(#class,'data-grid-table data-grid-fixed-row-table')]//span[contains(#class,'lightning-table-cell-measure-header-value')][contains(text(),'Pace')]
but this seems to be too long of a locator for my test. Is there a shorter dynamic xpath locator that I can use? Here is the snippet of the code that contains the word:
<th data-row-index="0" data-column-index="0" data-fixed-row="true" data-fixed-column="false" aria-selected="false" aria-hidden="false" id="data-grid-24-fixedrow0-col0" class="data-grid-table-cell data-grid-table-cell-start data-grid-header-cell" tabindex="0">
<div class="data-grid-table-cell-box" style="height: 17px;">
<div class="wave-table-cell-measure-header">
<span class="wave-table-cell-measure-header-text" data-tooltip="Pace" data-tooltip-on-truncation="true">
<span class="lightning-table-cell-measure-header-value" tabindex="-1">
<span class="header-icon-container">
<span class="slds-icon_container">
<svg aria-hidden="true" class="header-icon-sprite slds-icon">
<use xlink:href="/images/sprite.analytics.svg#formula"></use>
</svg>
<span class="slds-assistive-text">
Formula
</span>
</span>
</span>
Pace
</span>
</span>
</div>
</div>
<div class="data-grid-resize-slider" style="position: absolute; width: 0px; height: 0px;">
<input class="data-grid-resize-slider-input" aria-label="Pace Column Width: 115" type="range" tabindex="-1" min="35" max="1000" value="115">
</div>
</th>
The issue may be with the double [][] notation you are using for your //span element at the end. I've never seen that type of XPath syntax before, and I've always grouped queries into a single set of [].
You can use the following XPath:
//th/div/div//span[contains(text(), 'Pace']
This will get you the span element containing text 'Pace'.
If you just want to fix your existing XPath syntax, this might work too:
//table[contains(#class,'data-grid-table data-grid-fixed-row-table')]//span[contains(text(),'Pace') and contains(#class,'lightning-table-cell-measure-header-value')]
I've combined your last two queries into one using and operator.

VBA + IE choose index in context drop down that contain buttons that open pop-ups?

I'm trying to use VBA to click on a context drop down menu that contains links that open pop up boxes. However, using getElementById and .selectedIndex don't seem to be working as i Can't seem to find the right ID.
Also, when I click to inspect the context menu it gives me this code which doesn't seem right:
<div data-dojo-attach-point="rowNode" data-dojo-attach-event="onclick:_onClick" class="agsjsTOCRootLayer" title="Source Features" style="padding-left: 0px;">
Here is some source code for the dialog box that contains the drop downs with clickable buttons that open new dialog boxes:
<div id="dijit__Widget_1" widgetid="dijit__Widget_1">
<div class="agsjsTOCNode" id="TOCNode_id_source_features"widgetid="dijit__Templated_38">
<div data-dojo-attach-point="rowNode" data-dojo-attach-event="onclick:_onClick" class="agsjsTOCRootLayer" title="Source Features" style="padding-left: 0px;">
<span data-dojo-attach-point="contentNode" class="agsjsTOCContent">
<span data-dojo-attach-point="checkContainerNode"><img>
src="http://js.arcgis.com/3.13/dojo/resources/blank.gif" alt="" data-dojo-attach-point="iconNode" class="dijitTreeExpando dijitTreeExpandoClosed agsjsTOCIcon">
<div class="dijit dijitReset dijitInline dijitCheckBox" role="presentation" widgetid="dijit_form_CheckBox_16">
<input type="checkbox" role="checkbox" aria-checked="false" class="dijitReset dijitCheckBoxInput" data-dojo-attach-point="focusNode" data-dojo-attach-event="ondijitclick:_onClick" value="on" tabindex="0" id="dijit_form_CheckBox_16" style="user-select: none;">
</div>
Source Features
I'm trying to click on a drop down menu that appears only if your mouse is hovering over it to the right of the Source Feature title.
I've tried using the index selection code, but can't seem to find the right ID. Thanks.

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);

Selenium IDE not recording anything

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