Using watir webdriver, unable to press & hold a point and move to connecting the other point as there is no method for the same - watir

Here is the draggable element ->
#browser.div(:class => "start-module-loading").div(:class => 'mod-south').div(:class => 'ui-draggable')
and droppable element ->
#browser.div(:class => "syn-module syn-module-green").div(:class => "mod-north").div(:class => 'ui-droppable')
Want to connect draggable element to droppable one. But not able to do so as there is no method for this action. I am using watir webdriver with cucumber

You can use the Element#drag_and_drop_on method.
draggable = browser.div(id: 'node-866863') # the dot in start
drop_zone = browser.div(id: 'rec-294494') # the triangle in send sms
draggable.drag_and_drop_on drop_zone
The element ids are auto-generated, so you'll need to find a way to get the related dot/triangle of your block. If you know which modules you are working with, you could use the classes (and index). For example:
draggable = browser.div(id: 'module-0').div(class: 'ui-draggable')
drop_zone = browser.div(id: 'module-1').div(class: 'ui-droppable')
draggable.drag_and_drop_on drop_zone

Related

searchbox.send_keys() is unable to write any text on the bar by itself

[from selenium import webdriver
driver = webdriver.Firefox()
driver.get('https://youtube.com')
searchbox = driver.find_element("xpath",'//*[#id="search"]')
searchbox.send_keys("Akram Khan")
searchButton = driver.find_element("xpath",'//*[#id="search-icon-legacy"]')
searchButton.click()]
(https://i.stack.imgur.com/egHm1.png)
The function [searchbox.send_keys("Akram Khan")] have to be write the mentioned text("Akram Khan") inside the search box of YouTUbe.
So the problem is that when you first try to get the searchbox element with the current version that you had it was searching for the first occurrence of an element with id='search' which there is an element that is before not connected to the search box (therefore send_keys() to that element doesn't work). You can get the specific element that you want by specifying the tag that it is with your current code by doing (because the input element is what you want to be sending your response to):
searchbox = driver.find_element("xpath",'//input[#id="search"]')
#id='search' is reflecting to list of elements so use unique element like #name='search-query'

Drag and drop using nightwatch

I am trying to drag and drop the element to particular location using drag and drop in nightwatch with selenium but when i drop more than i element to same droppable it is overlapping.
var dragAndDrop = require('html-dnd').codeForSelectors;
this.dragModule = function (draggable, droppable, posX, posY) {
browser.pause(3000);
var dndSimulateConfig = { dropOffset: [posX, posY] };
browser
.execute(dragAndDrop, [draggable, droppable, dndSimulateConfig])
.pause(2000);
};
It should not overlap i want in particular co-ordinates
locator1: can be xpath (or cssSelector) of your first element you want
to drag locator2: can be xpath (or cssSelector ) is where you want to
drop
this is tried and tested code, might be you need to little modify but
it's working great for me.
return browser
.useXpath()
.moveToElement(locator1, XOffset1, Yoffset1)
.pause(100) // if you want to give wait
.mouseButtonDown(0) // press click, down
.moveToElement(locator2, XOffset2, Yoffset2) // move to element
.mouseButtonUp(0); // press release , up
read here docs- http://nightwatchjs.org/api and search for "moveToElement"
how to call:
myFunction moveToSpecificElement(locator, x, y) {
return browser
.moveToElement(locator, x, y, function (result) {
this.assert.equal("your assertion goes here");
});
}
I was using html-dnd version 1.2.0. So drag and drop was overlapping. Use any older version of 'html-dnd' it will work.

Appcelerator adding elements before and after specific elements

Using appcelerator, how do you go about inserting elements before and after specific elements. Such as
<View id='element'>Some Content</View>
Using $.element.add() the new element will be inside it but i need it to go either before or after. In simple terms is there an equivalent to .before and.after in jQuery?
Many thanks
You can use the method insertAt (docs).
If the parent view's layout is horizontal or vertial, then you'll see the children views displayed according to their array positions.
There are 2 workarounds for insert elements before the actual views:
Save the $.elements.children in a array, and unshift the new elements to the array, and add all those views in array to the $.elements;
While you adding the views, set the left or top property (depending on your design), and every time you add a new child, run a loop of the children and increase their left or top property; ex (child views with 200):
$.elements.children[0].left = 0;
$.elements.children[1].left = 200;
$.elements.children[2].left = 400;

Telerik MVC Grid Filter

I was using Telerik MVC Grid in my project. I just wanted to change the dropdown value orders a bit. I googled for the requirement and found the filter dropdown options are handled by **telerik.grid.min.js file. But, I dont know how can i change the order from
Options by Default
Is Equal to
Is not equal to
Starts with
Contains
Does not contain
Ends with
Change to the below format
Contains
Does not contain
Starts with
Ends with
Is Equal to
Is not equal to
Can anybody tell me the possibilities that i can change the order of filter dropdown box ..
Thanks,
You can do it by JQuery simply by some codes like this :
$('#GRIDID').find(".t-filter").click(function () {
setTimeout(function () {
$(".t-filter-operator").html('<option value="substringof">Contains</option><option value="notsubstringof">Does not contain</option>');
});
});
NOTE : the above code is a sample, you should do a process to check what operators you have and then repopulate the items in desired order. You can find all allowed "option" tags by inspecting the rendered grid.
The easy way (if you're using MVC razor syntax)
#Html.Kendo().Grid<Model>().Columns(columns =>
{
columns.Bound(x => x.variableName);
})
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.Contains("Contains").DoesNotContain("DoesNotContain").WhateverYouNeed)
.ForEnums( dat => dat.Clear()
.IsEqualTo("Is Equal To"))
))
Here, the Clear() empties the options in the filter and then you can add the ones you want or even create your own custom ones there, simply place them there in the order that you want.
Have fun!

Java script drop down menu access Watir-web driver

I am having problems trying to access some a link in a drop down menu In a web site. When you put your cursor over the button, as shown in the first picture, the menu drops down. Below that is a picture of the webpage script. What i want to do is click the search specifications button inn the drop down menu.
the like of code would go something like this :
e.frame(:name => "content").frame(:name => "main").a(:index => 0).click.a(:index => 10).click
However, that is not a valid peace of code, i just don't know the right way of doing it.
< e.frame(:name => "content").frame(:name => "main")
=> #<Watir::Frame:0x7f74b4d4 located=false selector={:name=>"main"}>
irb(main):064:0> my_frame.a(:text => 'Operations').click
Watir::Exception::UnknownObjectException: unable to locate element, using {:text
=>"Operations", :tag_name=>"a"}
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir
-webdriver/elements/element.rb:365:in `assert_exists'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir
-webdriver/elements/element.rb:95:in `click'
from (irb):64
from C:/Ruby193/bin/irb:12:in `<main>'
irb(main):065:0>
The dropdown menu does not appear to be in the HTML part that you posted. It is likely further down in the HTML.
Instead of trying to locate by index, which can easily change, you could locate by text. Try:
my_frame = e.frame(:name => "content").frame(:name => "main")
my_frame.a(:text => 'Operations').click
my_frame.a(:text => 'Search Specifications').click
This assumes that the 'Search Specifications' link is also in the same frame as the 'Operations' link.
Try this:
myframe.a(:text, 'Operations').fire_event 'mouseover'
myframe.a(:text, 'Search Specifications').click
Not sure if this is perfect, but the idea is that you make the link in the drop down menu present after you select the drop down. Play around with other elements. The fire_event method is the best way I know to make the drop down menu present.

Resources