swipe and click a button protractor - angularjs

i need to swipe an item and need to click on a button in that item, i used this the test is success but i could not view that button
this test case is written to swipe left and make a button visible and click on that button
it('should delete a product',function(){
browser.driver.actions().mouseMove({x:-50,y:0}).perform();
browser.sleep(3000);
});
could someone help me to swipe
the delete button is
<ion-option-button ng-show="!userService.isOffline" class="button button-assertive button disable-user-behavior" on-tap="deleteLead(leads)">Delete</ion-option-button>

I am doing something similar, with an ion-list, with ion-items, and ion-option-buttons. My swipe works, and looks like this:
var elements = element(by.id("item-list")).all(by.tagName("ion-item"));
var item1 = elements.get(0);
item1.getLocation().then((location) => {
var startLocation = {
x: location.x + 300,
y: location.y + 50
}
var newLocation = {
x: startLocation.x - 100,
y: startLocation.y
};
browser.driver.touchActions()
.tapAndHold(startLocation)
.move(newLocation)
.perform();
}
So I think you should use touchActions() instead of actions()
By the way, does on-tap work? Why not using ng-click?

There is another solution if the above solution of using tapAndHold is not working for anyone. You can use also use flickElement.
const offset = {x: -50, y: 0};
const targetElement = element(by.css(`selector`)); // This should be the element which is visible on your screen and you want to swipe
await browser.driver.touchActions()
.flickElement(targetElement, offset, 200)
.perform();
The above code is to swipe left the element.
To swipe right you can use:
const offset = {x: 50, y: 0};

Related

How to add a vertical plot line in multiple line series and show the tooltip on Plot line in highchart

I am trying to add a plotline on click in multiple series line chart in reactjs. I am using stockchart of high chart, Please let me know how to add plotline with tooltip.
Sample Screenshot:
I prepared a demo which shows how to add the plotLine dynamically with the custom tooltip.
Demo: https://jsfiddle.net/BlackLabel/Lyr82a5x/
btn.addEventListener('click', function() {
chart.xAxis[0].addPlotLine({
value: 5.5,
color: 'red',
width: 2,
id: 'plot-line-1',
events: {
mouseover() {
let lineBBox = this.svgElem.getBBox();
tooltip.style.display = 'block';
tooltip.style.left = lineBBox.x + 'px';
},
mouseout() {
tooltip.style.display = 'none'
}
}
})
})
If something is unclear - feel free to ask.
API: https://api.highcharts.com/highcharts/xAxis.plotLines.events.mouseout
API: https://api.highcharts.com/class-reference/Highcharts.Axis#addPlotLine

Angularjs/ Jquery animate on a new div

I want to add an animation on a new div that i created after clicking on the save button. The animation works when the div exists already on the page (on an update) but it's not working on a new div :
$scope.save(bookId) = function {
$scope.books.unshift(newBook);
var bookDivContainer = $("#bookContainer-" + bookId);
bookDivContainer.animate({ opacity: '0.4' }, "fast");
bookDivContainer.animate({ opacity: '0.9' }, "slow");
}
There's a way to call animate on a new element just created ? something like .on ?
Thanks

Selenium Javascript move slider not working

Using Selenium Javascript
driver.wait(until.elementLocated(By.css(".handle.handler1")), 5000);
var slider = driver.findElement(By.css(".handle.handler1"));
slider.then(function (elem) {
driver.actions().dragAndDrop(elem, {x: 25, y: 0}).perform();
});
I tried to put this code in loop and I see slider is selected but it does not move

jQuery UI Draggable / Sortable 4 column w/ CSS Transitions - Erratic Behavior

I am creating a simple drag and drop layout that incorporates 4 columns with the use of CSS easing effects when positioning. I have tried multiple solutions but nothing solves the problem. Eventually this will be an angularjs app.
Heres the JSfiddle (this is four columns so spread your browser to view the whole layout)
You will notice when you drag a module that sometimes it will let you snap to the grid and show the "placeholder" and some times it won't.
Sometimes the ".placeholder" which is the ".marker" in my example will randomly place the .marker div above the containing li elements causing this to happen.
Link to marker image
Is there a way to force the element to always be on the bottom element of all the li items of a parent ul?
Any help would be greatly appreciated!
var stylesheet = $('style[name=impostor_size]')[0].sheet;
var rule = stylesheet.rules ? stylesheet.rules[0].style : stylesheet.cssRules[0].style;
var setPadding = function(atHeight) {
rule.cssText = 'border-top-width: '+atHeight+'px';
};
$('.button-up').click(function(){
updateWidgetData();
});
$('.main-area ul').sortable({
connectWith: '.column',
cursor: 'move',
placeholder: 'marker',
forcePlaceholderSize: true,
opacity: 0.4,
start: function(event, ui){
setPadding(ui.item.height());
},
stop: function(event, ui){
ui.item.css({'top':'0','left':'0'}); //Opera fix
if(!$.browser.mozilla && !$.browser.safari)
updateWidgetData();
var next = ui.item.next();
next.css({'-moz-transition':'none', '-webkit-transition':'none', 'transition':'none'});
setTimeout(next.css.bind(next, {'-moz-transition':'border-top-width 0.1s ease-in', '-webkit-transition':'border-top-width 0.1s ease-in', 'transition':'border-top-width 0.1s ease-in'}));
}
}).disableSelection();
function updateWidgetData() {
var items = [];
$('.column').each(function() {
var columnId=$(this).attr('id');
$('.dragbox', this).each(function(i) {
var item = {
id: $(this).attr('id'),
order : i,
column: columnId
};
items.push(item);
});
});
var sortorder = { items: items };
//Pass sortorder variable to server using ajax to save state
$.post('updatePanels.php', 'data='+$.toJSON(sortorder), function(response) {
if(response=="success")
$("#console").html('<div class="success">Saved</div>').hide().fadeIn(1000);
setTimeout(function() {
$('#console').fadeOut(1000);
}, 2000);
});
}

extjs4 catching the scroll event on panel

I have a tabpanel with chats on different tabs. Each tab panel has a chat and the discussions are sometime very long so, in my initComponent, I have a code to continuously scroll to bottom so I can show the latest messages:
setInterval ->
this.scrollBy 100000, 100000
, 100
which works fine for what it's supposed to do. The problem is that I sometimes want to see what I talked earlier and I have to scroll to top but this code obviously wouldn't let me. I implemented a hook:
setInterval ->
if not this.autoscroll_disabled
this.scrollBy 100000, 100000
, 100
and now I just have to catch the event when the user triggers a scroll on my panel so I can set autoscroll_disabled to true until he scrolls back to bottom again probably. Any idea how do I catch a scroll event on a panel in extjs?
Ext.require('*');
Ext.onReady(function () {
var content = [],
i = 1;
for (; i <=100; ++i) {
content.push('Line ' + i);
}
var p = new Ext.panel.Panel({
renderTo: document.body,
width: 200,
height: 200,
autoScroll: true,
title: 'Foo',
html: content.join('<br />')
});
p.getTargetEl().on('scroll', function(e, t) {
var height = p.getTargetEl().getHeight();
if (height + t.scrollTop >= t.scrollHeight) {
console.log('bottom');
}
});
});

Resources