Protractor - Element Not Visible when selecting Drop down.(but visible when selected manually) - automation

i have been searching for 2 days but i couldnt come to a solution, i want a drop down to be selected. When i click on the drop down using some element.all css locator it clicks on the drop down(Drop down Opens up but error displayed). so i tried to use linkText to open up the drop down(Opens up perfectly). But after that i was not able to select the option in the drop down. (Element Not Visible displayed). also i was not able to select the option through the linkText. below r the details
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right" style="margin-right:0px">
<li>
<div uib-dropdown="" style="margin-right: 5px;" class="dropdown">
Tenant
<a href="" id="simple-dropdown" uib-dropdown-toggle="" class="dropdown-toggle" aria-haspopup="true" aria-expanded="false">
<span class="breadcrumb ng-binding" style="padding-bottom: 2px; padding-top: 2px;">cust1</span>
</a>
<ul class="uib-dropdown-menu dropdown-menu" role="menu" aria-labelledby="single-button">
<!-- ngRepeat: tenant in tenantList --><li ng-repeat="tenant in tenantList" class="ng-scope">
<a ng-click="selectTenant(0)" href="">
<span ng-show="selectedTenant.Identity == tenant.Identity" class="glyphicon glyphicon-ok"></span>
<span ng-show="selectedTenant.Identity != tenant.Identity" style="margin-left: 17px" class="ng-hide"></span>
<span class="ng-binding">cust1</span>
</a>
</li><!-- end ngRepeat: tenant in tenantList --><li ng-repeat="tenant in tenantList" class="ng-scope">
<a ng-click="selectTenant(1)" href="">
<span ng-show="selectedTenant.Identity == tenant.Identity" class="glyphicon glyphicon-ok ng-hide"></span>
<span ng-show="selectedTenant.Identity != tenant.Identity" style="margin-left: 17px" class=""></span>
<span class="ng-binding">NewTenant1</span>
</a>
</li><!-- end ngRepeat: tenant in tenantList --><li ng-repeat="tenant in tenantList" class="ng-scope">
<a ng-click="selectTenant(2)" href="">
<span ng-show="selectedTenant.Identity == tenant.Identity" class="glyphicon glyphicon-ok ng-hide"></span>
<span ng-show="selectedTenant.Identity != tenant.Identity" style="margin-left: 17px" class=""></span>
<span class="ng-binding">cust2</span>
</a>
</li><!-- end ngRepeat: tenant in tenantList -->
</ul>
</div>
I tried to do through below ways to select but i cant make it work.
wait for the element to become visible.
LinkText
Options to select. (via repeater name as the option)
kindly help me out

element(by.partialLinkText('cust2')); i dono how come linktext is not working but partialLinkText is working. thanks for replies.

Would this suffice? I use this to identify dropdown elements which contain a specific label value...
this.clickDropChoice = function(dropdown, optionChoice) {
dropdown.element(by.cssContainingText('option', optionChoice)).click()
};

Related

Can't click with selenium on service console option of salesforce

i'm trying to automate Salesforce Service Console, but i'm having some troubles because the multiples iframes.
One thing i really need is to click on the option "Close all primary tabs", but everything i have tried is not working.
The weird thing is that although the click is done nothing happens, if i try to do a click on chrome inspector console using javascript the tabs are closed, also if i click manually the tabs are closed, but if is made this trought selenium/katalon although the click is done nothing happens.
I have discovered that the popup html source is not under an iframe but the render of the popup overlays a iframe which comes from the external page tab.
If i trick the webpage modifying the css with the inspector moving the popup more up, were there is not iframe, then the click is closing the tabs.
Also if i delete the iframe from the html, the click is closing the tabs.
So i understand that this could be the problem, but although i have tried switch to iframe still not working.
i'am using katalon to automate but also happens with selenium .
Can you help me?
code of the popup list
<div id="ext-comp-1031"
class="x-menu x-menu-floating x-layer"
style="position: absolute; z-index: 15000; visibility: visible; left: 1086px; top: 124px;">
<a class="x-menu-focus"
href="#"
onclick="return false;"
tabindex="-1"
id="ext-gen173"/>
<ul class="x-menu-list"
id="ext-gen174"
style="height: 158px;">
<li id="x-menu-el-ext-comp-1106"
class="x-menu-list-item">
<a id="ext-comp-1106"
class="x-menu-item tab-scroller-menu-item "
hidefocus="true"
unselectable="on"
href="#">
<img alt=""
src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
class="x-menu-item-icon hidden"
id="ext-gen526">
<span class="x-menu-item-text"
id="ext-gen527">
<div class="tabTitle">
<span class="tabText">External Page</span>
</div>
<img alt=""
src="/s.gif"
class="refresh-icon"
id="ext-gen538">
<div class="x-menu-item-icon burl-link third-position"
id="ext-gen539"/>
<img alt=""
src="/s.gif"
class="bookmark-icon bookmarkNoPin"
id="ext-gen540"></span>
</a>
</li>
<li id="x-menu-el-ext-comp-1107"
class="x-menu-list-item">
<a id="ext-comp-1107"
class="x-menu-item tab-scroller-menu-item x-tab-tabmenu-selected "
hidefocus="true"
unselectable="on"
href="#">
<img alt=""
src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
class="x-menu-item-icon hidden"
id="ext-gen528">
<span class="x-menu-item-text"
id="ext-gen529">
<div class="tabTitle">
<span class="tabText">External Page</span>
</div>
<img alt=""
src="/s.gif"
class="refresh-icon"
id="ext-gen541">
<div class="x-menu-item-icon burl-link third-position"
id="ext-gen542"/>
<img alt=""
src="/s.gif"
class="bookmark-icon bookmarkNoPin"
id="ext-gen543"></span>
</a>
</li>
<li id="x-menu-el-ext-comp-1108"
class="x-menu-list-item">
<a id="ext-comp-1108"
class="x-menu-item x-tab-tabmenu-menuItem"
hidefocus="true"
unselectable="on"
href="#">
<img alt=""
src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
class="x-menu-item-icon "
id="ext-gen530">
<span class="x-menu-item-text"
id="ext-gen531">Close all primary tabs</span>
</a>
</li>
<li id="x-menu-el-ext-comp-1109"
class="x-menu-list-item">
<a id="ext-comp-1109"
class="x-menu-item x-tab-tabmenu-menuItem"
hidefocus="true"
unselectable="on"
href="#">
<img alt=""
src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
class="x-menu-item-icon "
id="ext-gen532">
<span class="x-menu-item-text"
id="ext-gen533">Refresh all primary tabs</span>
</a>
</li>
<li id="x-menu-el-ext-comp-1110"
class="x-menu-list-item">
<a id="ext-comp-1110"
class="x-menu-item x-tab-tabmenu-menuItem"
hidefocus="true"
unselectable="on"
href="#">
<img alt=""
src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
class="x-menu-item-icon "
id="ext-gen534">
<span class="x-menu-item-text"
id="ext-gen535">Reopen last-closed tab</span>
</a>
</li>
<li id="x-menu-el-ext-comp-1111"
class="x-menu-list-item">
<a id="ext-comp-1111"
class="x-menu-item x-tab-tabmenu-menuItem"
hidefocus="true"
unselectable="on"
href="#">
<img alt=""
src="data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
class="x-menu-item-icon "
id="ext-gen536">
<span class="x-menu-item-text"
id="ext-gen537">Show keyboard shortcuts (SHIFT+K)</span>
</a>
</li>
</ul>
</div>
xpath i'am selecting
//*/text()[normalize-space(.)='Close all primary tabs']/parent::*

Language Setting in Prestashop

In Prestashop for English website, I need to show the Arabic Language selector and on the Arabic website I need to show English as a Language selector.
currently, it showing the current website language on the language selector bar. is there is a way to do this?
<div class="language-selector dropdown js-dropdown">
<span class="expand-more" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="language-dropdown">
<span><img class="lang-flag" src="{$urls.img_lang_url}{$current_language.id_lang}.jpg"/></span>
<span class="language-title">{$current_language.name_simple}</span>
<span class="dropdown-arrow"></span>
</span>
<ul class="dropdown-menu" aria-labelledby="language-dropdown">
{foreach from=$languages item=language}
<li {if $language.id_lang == $current_language.id_lang} class="current" {/if}>
<img class="lang-flag" src="{$urls.img_lang_url}{$language.id_lang}.jpg"/> {$language.name_simple}
</li>
{/foreach}
</ul>
</div>
Try this:
<div class="language-selector dropdown js-dropdown">
<span class="expand-more" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="language-dropdown">
<span><img class="lang-flag" src="{$urls.img_lang_url}{$current_language.id_lang}.jpg"/></span>
<span class="language-title">{$current_language.name_simple}</span>
<span class="dropdown-arrow"></span>
</span>
<ul class="dropdown-menu" aria-labelledby="language-dropdown">
{foreach from=$languages item=language}
{if $language.id_lang != $current_language.id_lang}
<li>
<img class="lang-flag" src="{$urls.img_lang_url}{$language.id_lang}.jpg"/> {$language.name_simple}
</li>
{/if}
{/foreach}
</ul>
</div>

Add dynamic items in bootstrap carousel /asp.net mvc5

So this is the view :
e#model IEnumerable<CMSFC.Models.ContentHtml>
<div id="my-carousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
#{int i = 0;}
#foreach (var item in Model)
{
i++;
var active = i == 1 ? "active" : "";
<div class="item #active">
<a href="#Url.Action("Details", "ContentHtml", new { Id = item.Id })">
<img src="#Url.Content(item.Ctl)" alt="" height="500" width="500">
</a>
</div>
}
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
I have problems with left and right controls , when i touch them , they are not affected , slides just move on automatically , but left and right controls arent working.
In the left and right controls, you define href=#myCarousel instead of href=#my-carousel.

How can I share the dropdown menu definition accross multiple buttons

Each line in my table have a dropdown menu that show "Edit, Delete". If i have 100 lines in my table, i have 100 identical dropdown menus definition.
If is possible to define only one dropdown menu and use it for all my dropdown buttons? It seems to work but the dropdown menu is not shown at the right place. Is there a way to tell the dropdown menu to change his position to another one?
<a data-toggle="dropdown" href="#unique-dropdown">Button1</a>
<a data-toggle="dropdown" href="#unique-dropdown">Button2</a>
<div class="dropdown" id="unique-dropdown">
<ul class="dropdown-menu">
<li><i class="fa fa-pencil fa-fw"></i> Edit</li>
<li><i class="fa fa-trash-o fa-fw"></i> Delete</li>
</ul>
</div>
actually, you were really close to get what you wanted...
look this sample: http://jsfiddle.net/1jfe3wju/2/
html:
<a class="uniquedd" data-toggle="dropdown" aria-expanded="false" data-info="idofwhatyouwanttoeditordelete" href="#unique-dropdown">Button1</a>
<a class="uniquedd" data-toggle="dropdown" aria-expanded="false" data-info="otheridofwhatyouwanttoeditordelete" href="#unique-dropdown">Button2</a>
<div class="dropdown" id="unique-dropdown">
<ul class="dropdown-menu">
<li><i class="fa fa-pencil fa-fw"></i> Edit</li>
<li><i class="fa fa-trash-o fa-fw"></i> Delete</li>
</ul>
</div>
js:
$('.uniquedd').click(function(e) {
e.preventDefault();
var that = $(this);
var p = that.offset();
actOverWhat = that.data('info');
//change the actions of the buttons edit and delete
//check if open
isOpen = $("#unique-dropdown").hasClass('open');
if( isOpen ) {
that.dropdown('toggle');
}
$("#unique-dropdown").offset({ top: (p.top + 15), left: p.left });
});
offset is document related, so probably if the page is large won't help, but you have jquery .position();
You could use less js code. All you need to do is "Append" your class="dropdown-menu" to the class="dropdown" div each time you click an element that should show the menu.
Look at this example: https://jsfiddle.net/espriella/b4mztvnz/
$CHdropdown = $('#ColumnHeaderDropdownId');
$('.sharingdropdown').click(function(e) {
$(this).append($CHdropdown);
});
And this is the HTML sample:
<table class="table table-striped table-bordered" id="ChartContentGridId">
<thead>
<tr>
<th>
<div contenteditable style="float:left">Series 1</div>
<div class="dropdown sharingdropdown" style="float:right">
<button class="btn btn-xs btn-success dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-caret-down" aria-hidden="true"></i>
</button>
</div>
</th>
<th>
<div contenteditable style="float:left">Series 2</div>
<div class="dropdown sharingdropdown" style="float:right">
<button class="btn btn-xs btn-success dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-caret-down" aria-hidden="true"></i>
</button>
</div>
</th>
<th width="20px"></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<ul class="dropdown-menu pull-right" id="ColumnHeaderDropdownId">
<li><i class="fa fa-pencil"></i> Edit</li>
<li><i class="fa fa-times"></i> Delete</li>
</ul>

Bootrstap 3 - list group with accordion functionality

<div class="list-group" id="menu">
MESSAGES <span class="label label-info">5</span> <span class="glyphicon glyphicon-envelope pull-right"></span>
<div id="sm" class="sublinks collapse">
<a class="list-group-item small"><span class="glyphicon glyphicon-chevron-right"></span> inbox</a>
<a class="list-group-item small"><span class="glyphicon glyphicon-chevron-right"></span> sent</a>
</div>
TASKS <span class="glyphicon glyphicon-tag pull-right"></span>
<div id="sl" class="sublinks collapse">
<a class="list-group-item small"><span class="glyphicon glyphicon-chevron-right"></span> saved tasks</a>
<a class="list-group-item small"><span class="glyphicon glyphicon-chevron-right"></span> add new task</a>
</div>
ANOTHER LINK ...<span class="glyphicon glyphicon-stats pull-right"></span>
</div>
In spite of both <a> got data-parent="#menu", none of them appearing triggers other to hide. How to update this code to hide one sublinks as other are visible?
The #menu must be a parent of the list-group, and the list-group needs to have the panel class.
http://www.bootply.com/tGF9MEGbLM