Not able to click on element with unselectable='on' in chrome using webdriver - selenium

There is a drop down with an arrow on the side which opens up a sub menu. I am not able to click on the dropdown in chrome whereas its working in ie.
I tried hover and click and actions build too. But it's not working.
The code is as follows:
<div id="navigatortab" class=" x-plain undefined sd_nav_tabpanel x-border-panel" style="left: 0px; top: 0px; width: 1600px;">
<div id="ext-gen32" class="support-servicedesk-navigator">
<table id="ext-comp-1014" class="x-btn support-servicedesk-sb support-servicedesk-sbactive caseMru x-btn-noicon" cellspacing="0" style="width: 180px; height: 26px; background-image: none; background-color: transparent;">
<tbody class="x-btn-small x-btn-icon-small-left">
<tr>
<tr>
<td class="x-btn-ml">
<td class="x-btn-mc">
<em id="ext-gen41" class="x-btn-split" unselectable="on">
<button id="ext-gen33" class=" x-btn-text" type="button">
<div class="mruIcon"></div>
<span>Cases</span>
</button>
</em>
</td>
<td class="x-btn-mr">
</tr>
<tr>
</tbody>
</table>
</div>

Related

How Do I Click a div dropdown menu using VBA IE automation

Have the following DIV class, where you click on the bottom it will create a drop down menu. In browser, you can click it with mouse, however with IE automation with VBA. I tried the ".click" method and doesn't work.
I also tried the FireEvent with "onclick" "onchange" "onmouseover" and nothing works. Trying to see if there is any other solution
<div id="add12" style="width: 47px; height: 23px; white-space: nowrap;
position: static;"
controltype="DropDown" param="par">
<input name="ct10115" id="ddl" type="hidden" value="E">
<input class="ffb-input" id="input" style="width: 13px;" maxlength="1"
autocomplete="off">
<span class="ffb-arrow ui-button ui-widget ui-state-default ui-corner-Allui-button-text-icon-primary" id="teste2" role="button" ariadisabled="false" style="position:
static;">
<span class="ui-button-icon-primary ui-icon ui-icon-triangle-1-s"
style="left: 0px; top: 0px; margin-top: 0px; position: static;"></span>
<span class="ui-button-text"></span>
</span>
<div class="ffb" id="example11" style="left: 0px; top: 29px; width: 450px; display: none; z- index: 21; opacity: 0.999;">
<div class="content" style="height: auto; max-height: 200px;" scrolltop="0">
<div class="row" id="A" val="A" std_phase_cd="A" std_nm="A_">
<table>
<tbody>
<tr>
<td style="width: 45px;">A </td>
<td>none A </td>
</tr>
</tbody>
</table>
</div>
<div class="row" id="B" val="B" std__cd="B" std_nm="1">
<table>
<tbody>
<tr>
<td style="width: 45px;">B </td>
<td>none1 </td>
</tr>
</tbody>
</table>
</div>
</div>
<div></div>
</div>
</div>
ok I got it figured out.
So I use the dev tool on browser, and found the event e.g. click, mousedown etc.
then I use IE.dipatchEvent to trigger the click event.

I cannot click a button/element when the css of the element contains only an ID

I am attempting to click a button using Robot Framework - Selenium.
The element of the button looks like this:
<div id="isc_7A" eventproxy="addButton" onfocus="isc.EH.focusInCanvas(addButton_label,true);" onblur="if(window.isc)isc.EH.blurFocusCanvas(addButton_label,true);" tabindex="-1" style="position: absolute; left: 6px; top: 1px; width: 65px; height: 22px; z-index: 201603; overflow: visible; cursor: pointer;" onscroll="return addButton.$lh()">
<div id="isc_79" eventproxy="addButton" style="position: relative; visibility: inherit; z-index: 201603; cursor: pointer;">
<table cellspacing="0" cellpadding="0" width="1" height="22">
<tbody>
<tr>
<td nowrap="true" class="stretchImgButton" align="center" valign="center" tabindex="-1" onfocus="addButton_label.$47()">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="stretchImgButton" style="margin:0px;border:0px;padding:0px;background-image:none;background-color:transparent;-webkit-box-shadow:none;box-shadow:none;font-size:1px;padding-right:6px"><img src="https://hq-foxtrot-s1.hq-foxtrot.defencetest.local:10006/journal/images/tag_new.png" width="16" height="16" align="absmiddle" name="isc_79addButton_label$4u" style="vertical-align:middle" eventpart="icon" border="0" suppress="TRUE"></td>
<td class="stretchImgButton" style="margin:0px;border:0px;padding:0px;background-image:none;background-color:transparent;-webkit-box-shadow:none;box-shadow:none;" nowrap="true">New Tag</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</div>
My tests in PyCharm looks like this:
*** Settings ***
Documentation Create a new tag
Library SeleniumLibrary
*** Test Cases ***
This is some basic info about the test
[Documentation] This is some basic info about the test
[Tags] Smoke
Open Browser [website] chrome
Sleep 10sec
wait until page contains element css=#isc_7A
click button css=#isc_7A
I've also tried using the xpath of the element, but still no success. The xpath looks like this:
//*[#id="isc_7A"]

Unable to select Un Ordered List of 2 similar drop down values through selenium webdriver

I’m trying to automate and select the drop down values.
2 fields are having same drop down values (i.e.). Yes and No and both field has similar HTML code . So unable to find unique Xpath in order to click on second field and it is throwing an org.openqa.selenium.ElementNotInteractableException exception. Since the tag name is not SELECT, so I couldn’t use SELECT Class.
HTML Code:
1st Field
<table id="ssl" class="x-field dropdown x-form-item x-box-item x-field-default x-vbox-form-item x-form-dirty" style="margin: 0px; width: 660px; table-layout: fixed; left: 9px; top: 36px;" cellpadding="0">
<tbody>
<tr id="ssl-inputRow">
<td id="ssl-labelCell" class="x-field-label-cell" style="" halign="left" width="385" valign="top">
<label id="ssl-labelEl" class="x-form-item-label x-form-item-label-left" for="ssl-inputEl" style="width:380px;margin-right:5px;">Use SSL to connect to NetScaler </label>
</td>
<td id="ssl-bodyEl" class="x-form-item-body x-form-trigger-wrap-focus" colspan="2" role="presentation" style="width: 100%;">
<table id="ssl-triggerWrap" class="x-form-trigger-wrap" style="width: 100%; table-layout: fixed;" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td id="ssl-inputCell" class="x-form-trigger-input-cell" style="width: 100%;">
<div id="ext-gen1668" class="x-hide-display x-form-data-hidden" role="presentation"></div>
<input id="ssl-inputEl" class="x-form-field x-form-text x-form-focus x-field-form-focus x-field-default-form-focus" autocomplete="off" name="ssl" readonly="readonly" style="width: 100%; -moz-user-select: text;" aria-invalid="false" data-errorqtip="" type="text">
</td>
<td id="ext-gen1667" class="x-trigger-cell" style="width:22px" valign="top">
<div id="ext-gen1666" class="x-trigger-index-0 x-form-trigger x-form-arrow-trigger x-form-trigger-last x-unselectable" role="button" style="-moz-user-select: none;"></div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
2nd Field:
<table id="isDiscovery" class="x-field dropdown x-form-item x-box-item x-field-default x-vbox-form-item x-form-dirty" style="margin: 0px; width: 660px; table-layout: fixed; left: 9px; top: 67px;" cellpadding="0">
<tbody>
<tr id="isDiscovery-inputRow">
<td id="isDiscovery-labelCell" class="x-field-label-cell" style="" halign="left" width="385" valign="top">
<label id="isDiscovery-labelEl" class="x-form-item-label x-form-item-label-left" for="isDiscovery-inputEl" style="width:380px;margin-right:5px;">Discover StoreFront hosts using this NetScaler </label>
</td>
<td id="isDiscovery-bodyEl" class="x-form-item-body" colspan="2" role="presentation" style="width: 100%;">
<table id="isDiscovery-triggerWrap" class="x-form-trigger-wrap" style="width: 100%; table-layout: fixed;" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td id="isDiscovery-inputCell" class="x-form-trigger-input-cell" style="width: 100%;">
<div id="ext-gen1671" class="x-hide-display x-form-data-hidden" role="presentation"></div>
<input id="isDiscovery-inputEl" class="x-form-field x-form-text" autocomplete="off" name="isDiscovery" readonly="readonly" style="width: 100%; -moz-user-select: text;" aria-invalid="false" data-errorqtip="" type="text">
</td>
<td id="ext-gen1670" class="x-trigger-cell" style="width:22px" valign="top">
<div id="ext-gen1669" class="x-trigger-index-0 x-form-trigger x-form-arrow-trigger x-form-trigger-last x-unselectable" role="button" style="-moz-user-select: none;"></div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
Tried Xpath (but it is failing to select 2nd field)
1st field xpath:
.//*[#id='ssl-inputEl']//following::div[contains(#id,'boundlist-')]/div/ul/li[2][contains(text(), 'No')]
.//*[#id='ssl-inputEl’]//following::div[contains(#id,'boundlist-')]/div/ul/li[1][contains(text(), ‘Yes’)]
.//*[contains(#id,'boundlist-')]/div/ul/li[1][contains(text(), 'Yes')]
.//*[contains(#id,'boundlist-')]/div/ul/li[2][contains(text(), 'No')]
2nd field xpath:
.//*[#id='isDiscovery-inputEl']//following::div[contains(#id,'boundlist-')]/div/ul/li[2][contains(text(), 'No')]
.//*[#id='isDiscovery-inputEl']//following::div[contains(#id,'boundlist-')]/div/ul/li[1][contains(text(), ‘Yes’)]
.//*[contains(#id,'boundlist-')]/div/ul/li[1][contains(text(), 'Yes')]
.//*[contains(#id,'boundlist-')]/div/ul/li[2][contains(text(), 'No')]

Making Bootstrap table-striped table transparent

I want to make the table transparent and I want to see the background image through the table list which is striped with different colors.
I have tried the following but it didn't work.
<style> #loading {
position: absolute; width: 100%; height: 100%; background: url('http://www.jettools.com/images/animated_spinner.gif') no-repeat center center;
}
</style>
<div id="loading"></div>
<table style="background: transparent !important;">
<thead>
<th></th><th></th><th></th><th></th>
</thead>
<tbody style="background: transparent !important;" >
<tr>
<td title="">
</td>
<td title=""
</td>
<td title="">
</td>
<td title="">
</td>
</tr>
</tfoot> </tfoot>
</tbody>
</table>

Selenium Webdriver: Read a table completely

Scenerio:In a webpage there are few tables present. I want to read one of the table completely, but the problem is only 10 rows are displayed, for rest i have to scroll down. Actually originally only 10 row are available, when we scroll rest of the filed are rendered.
To solve this i thought i will simulate key down and keep reading, but the problem is even the xpath is not consistent through out so cannot put in a loop too. Xpath for few different cells are:
html/body/div[2]/form/div[1]/div[2]/div/div[2]/div/div[2]/div/div[2]/div/div[2]/div/span/div[1]/div/div/div/div[2]/div/div[2]/table/tbody/tr[1]/td[1]
html/body/div[2]/form/div[1]/div[2]/div/div[2]/div/div[2]/div/div[2]/div/div[2]/div/span/div[1]/div/div/div/div[2]/div/div[2]/table[2]/tbody/tr[3]/td[1]
html/body/div[1]/form/div[1]/div[2]/div/div[2]/div/div[2]/div/div[2]/div/div[2]/div/span/div[1]/div/div/div/div[2]/div/div[2]/table[1]/tbody/tr[10]/td[1]
In what way can i get data in all the cells ?
HTML Source:
<div id="pt1:ph1" class="x6v">
<table class="xtb" width="0" cellspacing="0" cellpadding="0" border="0" summary="">
<div class="xvp">
<div>
<div id="pt1:pc1" class="xpb xph" _afrclmwmn="['c1','c2','c3','c4','c5','c6','c7','c8','c9','c10']" _afrac="pt1:pc1:md1" style="height: 282px;">
<div id="pt1:pc1::_ahTp" style="height:auto">
<div id="pt1:pc1::_ahCt">
<div id="pt1:pc1:md1" class="xpj xpb" _leafcolclientids="['pt1:pc1:md1:c1','pt1:pc1:md1:c2','pt1:pc1:md1:c3','pt1:pc1:md1:c4','pt1:pc1:md1:c5','pt1:pc1:md1:c6','pt1:pc1:md1:c7','pt1:pc1:md1:c8','pt1:pc1:md1:c9','pt1:pc1:md1:c10','pt1:pc1:md1:c11','pt1:pc1:md1:c12']" _afrfilterable="true" _afrautohr="10" _afrhcc="0" _afrpcid="pt1:pc1" tabindex="0" style="height: 234px;">
<div id="pt1:pc1:md1::ch" class="xz5" _afrcolcount="12" style="overflow: hidden; position: relative; width: 753px;">
<div id="pt1:pc1:md1::db" class="xyy" _afrcolcount="12" style="position: relative; width: 753px; overflow: hidden; height: 170px; z-index: 1;">
<table class="xyz xzr" cellspacing="0" _startrow="0" _rowcount="44" _selstate="{'0':true}" _totalwidth="1260" style="table-layout:fixed;position:relative;width:1260px;">
<tbody>
<tr class="xzn p_AFSelected" _afrrk="0">
<td class="xzk" nowrap="" style="width:100px;">12</td>
<td class="xzk" nowrap="" style="width:100px;">A12</td>
<td class="xzk" nowrap="" style="width:100px;">B12</td>
<td class="xzk" nowrap="" style="width:100px;">B12</td>
<td class="xzk" nowrap="" style="width:100px;">C12</td>
<td class="xzk" nowrap="" style="width:100px;">D12</td>
<td class="xzk" nowrap="" style="width:100px;"> </td>
<td class="xzk" nowrap="" style="width:100px;">K12</td>
<td class="xzk" nowrap="" style="width:100px;"> </td>
<td class="xzk" nowrap="" style="width:100px;"> </td>
<td class="xzk" nowrap="" style="width:100px;"> </td>
<td class="xzk" nowrap="" style="width:100px;">G12</td>
</tr>
<tr class="xzn" _afrrk="1">
<tr class="xzn" _afrrk="2">
<tr class="xzn" _afrrk="3">
<tr class="xzn" _afrrk="4">
<tr class="xzn" _afrrk="5">
<tr class="xzn" _afrrk="6">
<tr class="xzn" _afrrk="7">
<tr class="xzn" _afrrk="8">
<tr class="xzn" _afrrk="9">
</tbody>
</table>
</div>
<div id="pt1:pc1:md1::sm" class="xzu" style="position:absolute;display:none"></div>
<div id="pt1:pc1:md1::ri" class="xz0" style="position:absolute;display:none;overflow:hidden"></div>
<div id="pt1:pc1:md1::dataW" style="display:none"></div>
<div id="pt1:pc1:md1::scroller" tabindex="-1" style="position: absolute; overflow: auto; z-index: 0; width: 770px; top: 46px; height: 187px; right: 0px;">
</div>
</div>
<div id="pt1:pc1::_ahBt" style="height:auto">
<div id="pt1:pc1:_clmCxt" style="display:none">
<div id="pt1:pc1:_PCPop" style="display:none">
<div id="pt1:pc1::_dchDlgC" style="display:none">
</div>
</div>
</div>
</div>
HTML after scrolling.
<div id="pt1:ph1" class="x6v">
<table class="xtb" width="0" cellspacing="0" cellpadding="0" border="0" summary="">
<div class="xvp">
<div>
<div id="pt1:pc1" class="xpb xph" _afrclmwmn="['c1','c2','c3','c4','c5','c6','c7','c8','c9','c10']" _afrac="pt1:pc1:md1" style="height: 282px;">
<div id="pt1:pc1::_ahTp" style="height:auto">
<div id="pt1:pc1::_ahCt">
<div id="pt1:pc1:md1" class="xpj xpb" _leafcolclientids="['pt1:pc1:md1:c1','pt1:pc1:md1:c2','pt1:pc1:md1:c3','pt1:pc1:md1:c4','pt1:pc1:md1:c5','pt1:pc1:md1:c6','pt1:pc1:md1:c7','pt1:pc1:md1:c8','pt1:pc1:md1:c9','pt1:pc1:md1:c10','pt1:pc1:md1:c11','pt1:pc1:md1:c12']" _afrfilterable="true" _afrautohr="10" _afrhcc="0" _afrpcid="pt1:pc1" tabindex="0" style="height: 234px;">
<div id="pt1:pc1:md1::ch" class="xz5" _afrcolcount="12" style="overflow: hidden; position: relative; width: 753px;">
<div id="pt1:pc1:md1::db" class="xyy" _afrcolcount="12" style="position: relative; width: 753px; overflow: hidden; height: 170px; z-index: 1;">
<table class="xyz xzr" cellspacing="0" _startrow="10" _rowcount="44" style="table-layout:fixed;position:relative;width:1260px;">
<tbody>
<tr class="p_AFFocused p_AFSelected xzn" _afrrk="10">
<tr class="xzn" _afrrk="11">
<tr class="xzn" _afrrk="12">
<tr class="xzn" _afrrk="13">
<tr class="xzn" _afrrk="14">
<tr class="xzn" _afrrk="15">
<tr class="xzn" _afrrk="16">
<tr class="xzn" _afrrk="17">
<tr class="xzn" _afrrk="18">
<tr class="xzn" _afrrk="19">
</tbody>
</table>
<table class="xyz xzr" cellspacing="0" _startrow="20" _rowcount="44" style="table-layout:fixed;position:relative;width:1260px;">
</div>
<div id="pt1:pc1:md1::sm" class="xzu" style="position: absolute; display: none; z-index: 5000; visibility: visible; top: 120px; right: 25px;">Fetching Data...</div>
<div id="pt1:pc1:md1::ri" class="xz0" style="position:absolute;display:none;overflow:hidden"></div>
<div id="pt1:pc1:md1::dataW" style="display:none"></div>
<div id="pt1:pc1:md1::scroller" tabindex="-1" style="position: absolute; overflow: auto; z-index: 0; width: 770px; top: 46px; height: 187px; right: 0px;">
</div>
</div>
<div id="pt1:pc1::_ahBt" style="height:auto">
<div id="pt1:pc1:_clmCxt" style="display:none">
<div id="pt1:pc1:_PCPop" style="display:none">
<div id="pt1:pc1::_dchDlgC" style="display:none">
</div>
</div>
</div>
</div>
<div id="pt1:ph2" class="x6v">
</span>
</div>
</div>
try to use this approach:
1) actions builder, advanced user API
MoveMouseAction method in particular - Moving the mouse from its current location to another element.
you can get here more info about actions builder
2) also dont forget to use fluent wait until web element is rendered
public WebElement fluentWait(final By locator){
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(30, TimeUnit.SECONDS)
.pollingEvery(5, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class);
WebElement foo = wait.until(
new Function<WebDriver, WebElement>() {
public WebElement apply(WebDriver driver) {
return driver.findElement(locator);
}
}
);
return foo; } ;
By xpathElem=By.xpath("html/body/div[2]/form/div[1]/div[2]/div/div[2]/div/div[2]/div/div[2]/div/div[2]/div/span/div[1]/div/div/div/div[2]/div/div[2]/table/tbody/tr[1]/td[1]");
//getting data from cells
fluentWait(xpathElem).getText().trim();
hope this somehow helps you ;-)