Selecting a element in a drop-down menu in protractor - protractor

I have a drop-down menu on my page. My goal for protractor testing is to click one of the options of this drop-down menu and have protractor check the results:
<ul class="dropdown">
<li class="nav-header">portfolio</li>
<li class="divider"></li>
<li class="dropdown-submenu"> ... </li>
<li ng-repeat="p in user.portfolios">
<!-- this is the option we will click for our testing -->
<a href ng-click="displayPortfolio(p)>Portfolio 1 </a>
</li>
<li ng-repeat="p in user.portfolios">
<a href ng-click="displayPortfolio(p)>Portfolio 2 </a>
</li>
<li ng-repeat="p in user.portfolios">
<a href ng-click="displayPortfolio(p)>Portfolio 3 </a>
</li>
</ul>
my protractor test looks something like:
it('should display relevant portfolio when clicked',function(){
ptor.ignoreSynchronization = true;
element.all(by.xpath("//a[#ng-click='displayPortfolio(p)'])).then(function(list){
list[0].click();
expect(... some assertion here);
});
ptor.ignoreSynchronization = false;
}
Just in case you were wondering, ptor.ignoreSynchronization is enabled because my web-page is constantly polling the backend for some updates.
Protractor throw the following error when I run the test:
ElementNotVisisbleError: element not visible
I don't quiet understand what this error is about. The element is surely visible since when I do view source of the page, I can see it in the DOM structure.
Kindly advice

I have handled same case by setting value directly. locate the element and set the value using "sendKeys".
Try the same for your scenario.

Have you tried using the repeater locator?
it('should display relevant portfolio when clicked',function(){
var elements = element.all(by.repeater('p in user.portfolios'));
elements.get(0).click().then(function(){
expect(... some assertion here);
});
}

Related

Crystal report HTML RTL direction not working with Arabic

I am trying to generate a report which gets data as html from database to be displayed as multi records in ARABIC. Data is being retrieved successfully, but the problem is when I try to display Arabic Unordered List (<ul> and <li> html tags), items are being displayed from left to right instead of right to left. Below is the output of all trials:
I have tried multiple structures but I got same result:
Trial 1:
: الأرقام هي
<ul style="direction:rtl;" dir="rtl">
<li>واحد</li>
<li>إثنان</li>
<li>ثلاثة</li>
</ul>
Trial 2:
: الأرقام هي
<ul style="direction:rtl; text-align:right;" dir="rtl">
<li>واحد</li>
<li>إثنان</li>
<li>ثلاثة</li>
</ul>
Trial 3:
: الأرقام هي
<ul style="direction:rtl; text-align:right;" dir="rtl">
<li style="direction:rtl; text-align:right;" dir="rtl">واحد</li>
<li style="direction:rtl; text-align:right;" dir="rtl">إثنان</li>
<li style="direction:rtl; text-align:right;" dir="rtl">ثلاثة</li>
</ul>
Nothing has changed in all trials, any help?
Update
Horizontal Alignment and Reading Order of crystal report formula are set to right;
I have also added a new trial where I have put the whole content in a new div, but unfortunately all text was displayed from left to right:
Trial 4:
<div style="direction:rtl; text-align: right" >
: الأرقام هي
<ul style="direction:rtl;" dir="rtl">
<li>واحد</li>
<li>إثنان</li>
<li>ثلاثة</li>
</ul>
</div>
Crystal has limited support for html interpretation.
One way to get around this is to create or get a UFL that turns the HTML to an image. Crystal can dynamically generate and load the image into the report (using the 'graphic location' property).
Here is an example using your text with a few tweaks:
I ended up by using the below:
: الأرقام هي
<ul align = "right" dir="rtl">
<li align = "right" >واحد</li>
<li align = "right" >إثنان</li>
<li align = "right" >ثلاثة</li>
</ul>
I hope this can help somebody

In Selenium how to select an option if the span class and div class are not unique

We have tabs called Community, Resources and Support which have the same section class Div Class and Span Class attributes as seen in the html code below.
How to "select" or choose one of the tabs and then traverse down the path to the links.
<section class="s-fn-item">
<div class="s-fn-wrapper-item">
<h5 class="s-fn-title-item">
<span class="s-fn-item-link">Community</span>
</h5>
<div class="s-fn-wrapper-sub-menu bg-base bg-shadow-down-medium fn- offscreen" style="display: block; height: 245px;">
<ul class="s-fn-sub-menu-item">
<li class="s-fn-promo-sub-menu-item">QA Community Home
</li>
<li class="s-fn-promo-sub-menu-item">Community Home
</li>
<li class="s-fn-promo-sub-menu-item">Community Events
</li>
</ul>
</div>
</div>
</section>
<section class="s-fn-item">
<div class="s-fn-wrapper-item">
<h5 class="s-fn-title-item">
<span class="s-fn-item-link">Resources</span>
</h5>
<div class="s-fn-wrapper-sub-menu bg-base bg-shadow-down-medium fn-offscreen" style="display: block; height: 227px;">
<ul class="s-fn-sub-menu-item">
<li class="s-fn-promo-sub-menu-item">Articles and How-Tos
</li>
<li class="s-fn-promo-sub-menu-item">Blog
</li>
Storymakers
Support
Support Home
Contact Us
Installation and Licensing
I agree with #user1433852 for using relative xpaths as they make life easier.. :) . I have formulated relative xpaths below to find the menu Community/Resources and then the xpath for a sub-menu item under them:
//span[.='Community']
This will select the 'span' element with the exact inner HTML or text as 'Community'.
//span[.='Community']/ancestor::div[#class='s-fn-wrapper-item']//a[#title='QA Community Home']
This will select the 'a' element with title 'QA Community Home' under the div element with class 's-fn-wrapper-item' which is the ancestor of the 'span' element with the exact inner HTML or text as 'Community'.
Similarly,
//span[.='Resources']
This will select the 'span' element with the exact inner HTML or text as 'Resources'.
//span[.='Resources']/ancestor::div[#class='s-fn-wrapper-item']//a[#title='Articles and How-Tos']
This will select the 'a' element with title 'Articles and How-Tos' under the div element with class 's-fn-wrapper-item' which is the ancestor of the 'span' element with the exact inner HTML or text as 'Resources'.
So, in both the cases above I am using the the primary items, i.e., Community and Resources to get to their submenu items, that are, QA Community Home and
Articles and How-Tos, respectively.

Knockoutjs sortable with helper:clone, doesn't clone and moves the original item

Strange issue, I am struggling for couple days. I have a simple knockoutjs sortable page that binds to 2 lists as below. I would like to move copy an item from list A to B. I tried passing helper: 'clone' in options as in documentation, but it doesn’t create a copy and moves the original item.
Here is the http://jsfiddle.net/a5FL5/13/, that shows the problem. Try moving item from list A to B, and it moves the original item, and no copy is created.
I haven’t been able to figure out what the issues. Any help is appreciated.
<div class="A">
<ul data-bind="sortable: { data:stagingList.filteredTodos , options: {helper: 'clone', connectToSortable: '.okay'}}">
<li data-bind="text: itemlist"> </li>
</ul>
</div>
<div class="B">
<ul data-bind="sortable: { data: dayList.dfilteredTodos }">
<li class="okay" data-bind="text: itemlist"> </li>
</ul>
</div>
Regards
Srini

Is it possible to implement dynamic form input rows (adding new row by clicking on Add) with Handlebars and Meteor?

I'm getting my hands dirty with Meteor, and I wanted to port this AngularJS app (http://simplydo.com/projector/) over as an exercise.
I'm having difficulty implementing adding dynamic input form rows to sections using Handlebars, and I've found no documentation anywhere that documents if this possible. It's a snap in Angular using ng-repeat, but I want to confirm if this is something that is possible in Handlebars or whether I need to use Jquery in order to achieve this.
Thanks in advance.
It's just as easy in Meteor
all you have to do is repeat the rows with {{#each rowData}} and have a button that adds a document to the collection. Here is an example:
In this template the rows for a page are shown. In order to add a row, the user has to click on the add image. The template is :
<template name="page">
{{#with page}}
<h3>{{title}}</h3>
{{#each rows}}
<div class="row-fluid page-row {{#if isSelected this}}selected-row{{/if}}">
... page content here
</div>
{{/each}}
{{/with}}
<div class="btn-toolbar">
<div class="pull-right">
<a id="add-row" href="#" data-toggle="tooltip" title="{{lbl 'add-page'}}">
<img src="/images/add.png" class="asset-icon"/>
</a>
<img src="/images/separator.png" class="asset-icon"/>
<a id="delete-row" href="#" data-toggle="tooltip" title="{{lbl 'delete-page'}}">
<img src="/images/delete.png" class="asset-icon"/>
</a>
</div>
</div>
</template>
the helpers for this template are:
Template.page.page = function () {
return Session.get("selected-page");
}
in order to add a page the click event for the add button is implemented:
"click #add-row": function (evt, template) {
var page = Session.get("selected-page");
Pages.update({_id: page._id}, ... add a new row here ...)
}
because the whole thing is reactive, the list of rows will redraw after the update on the Pages collection.

how to redirect pages in jsf 2?

i have a simple menu on jsf:
<h:panelGroup id="panelMenu">
<h:form id="menuForm">
<ul class="nav nav-tabs" id="myTab">
<li class="active"><h:outputLink value="contenido/Agrupaciones.xhtml"><h:outputText value="Agrupaciones" /></h:outputLink></li>
<li><h:outputLink value="contenido/Usuarios.xhtml" ><h:outputText value="Usuarios" /></h:outputLink></li>
<li><h:outputLink value="contenido/Modulos.xhtml" ><h:outputText value="Modulos" /></h:outputLink></li>
<li><h:outputLink value="contenido/Roles.xhtml" ><h:outputText value="Roles" /></h:outputLink></li>
</ul>
</h:form>
</h:panelGroup>
it works ok, but when im on one of my pages.. let say "users.xhtml" and from that page i go to another like "details" <h:outputLink value="../contenido/detalleUsuario.xhtml">, when i click again in my principal menu to go back to "users" the url looks like this:
contenido/contenido/Usuarios.xhtml when it should be contenido/Users.xhtml. so i get a "page not found error".
Use <h:link> instead of <h:outputLink>. The <h:link> treats the path as navigation case outcome and will always resolve it relative to the context path. So you can safely start the outcome with / without worrying about the context path.
<li class="active"><h:link value="Agrupaciones" outcome="/contenido/Agrupaciones.xhtml" /></li>
<li><h:link value="Usuarios" outcome="/contenido/Usuarios.xhtml" /></li>
<li><h:link value="Modulos" outcome="/contenido/Modulos.xhtml" /></li>
<li><h:link value="Roles" outcome="/contenido/Roles.xhtml" /></li>
Note that those links doesn't require a form at all. So the whole <h:form> as you've in your code is completely superfluous.