I'm using the selenium webdriver (python) to automate testing of an app that uses the fullcalendar js plugin library. However, I'm having trouble automating dragging and dropping events to the calendar.
After a lot of experimentation, I can see that the test code below moves the event element to the correct location. When this action is done by hand on the browser, the calendar square that you are hovering on turns blue and the event, when dropped, is added to the calendar. This does not happen when the event is moved via automation -- the calendar square does not turn blue, and the event, when dropped, returns to its original position.
How can I get the same drag and drop functionality under automation?
evt = self.sel.find_element_by_css_selector('#evt1')
cal_square = self.sel.find_element_by_css_selector('td[data-date=\'%s\']' % move_to_date.isoformat())
ActionChains(self.sel).click_and_hold(evt).move_to_element(cal_square).perform()
time.sleep(10)
ActionChains(self.sel).release().perform()
time.sleep(5)
Here's a link to at test case which demonstrates the issue:
https://gist.github.com/jenniferlianne/9353489
I have a problem with time while drag and drop. I need some wait after move_to_element and release, but after move_to_element.perform my mouse gets to the coordinates of dragged element and release over there. What can I do with that?
After a while I try this:
parent = driver.find_element_by_xpath("//*[contains(text(), 'Parent')]")
welcome_form = driver.find_element_by_id(link.my_forms["welcome_to_pdf_form"])
actions.click_and_hold(welcome_form).move_to_element(parent).click().perform()
I don't actually know why it works. I thought it will generate click after click and I will get an error but works fine.
My problem was that -- as Micheal pointed out -- after the move, the mouse was reverting back to original element position and doing the release() there. You can supply the release() function with the element where you want the 'mouse up' to happen.
For whatever reason, this works:
ActionChains(self.sel).click_and_hold(
evt).move_to_element(cal_square).release(cal_square).perform()
While this does not:
ActionChains(self.sel).drag_and_drop(evt, cal_square).perform()
Related
I have a list of items. I want to be able to handle both an onClick and onLongPress events. For this purpose, I am using this hook here.
My issue is that on mobile when you start to press on the item, but them move your finger out of the "hitbox" (finger no longer on the item), this will still trigger a onLongPress event. Expected behaviour is that the user should keep their finger on the item when long pressing, and only then should the event trigger.
I found this library which doesn't have this issue but ONLY works on mobile, and I'm trying to make my app compatible with all platforms, including the browser (as a PWA): this one
Any sort of advice on how to move forward would be greatly appreciated.
As anyone can notice it, in the schedule external drag drop demo , someone can drag the event from the TreeView list and when it get near to the right page edge then the page scrolls to the right.
Here is a screenshot showing it.
It's occuring also in our app and it's rather annoying.
We wish there will be a fix for this issue.
Greetings from Syncfusion Support.
We have checked your reported problem that dragging a TreeView node that produces the scroller in the output web page. Currently, we don’t have any property to prevent the scroll when dragging a TreeView node. However, we have already considered this as a feature from our end. It will be included in our Volume 2 Release which is expected to be released in June 2020.
Track the below link to know the feature status.
https://www.syncfusion.com/feedback/13575/need-to-provide-the-option-to-set-the-drag-area-in-treeview-component
But, you can resolve your issue by setting the target for dragArea of TreeView’s drag object in the created event. When setting the target, you can drag the element only inside the target element. It prevents the element from scrolling exceeding that element.
Please, check out the sample with the above explained solution.
Sample: https://stackblitz.com/edit/react-jqzozo-gqpyve?file=index.js
onCreate(){
this.treeObj.dragObj.dragArea = "body";
}
If you go mouse over on above area then 3m,6m,1y and all are visible. If you go mouse down then it disable. How to handle this type of case in selenium.
As per my understanding you will have to use Action classes's mouse hover to get the pop up for months.
....Use developer tool to highlight the chart on which you need to hover the mouse, now hover the mouse to get those month's pop ups. and see in developer tools for changes in dom so that you can get their xpaths. Make sure you use "driver.click" to click on months. you can try xpath= //*[.='3m']. Just try to find out exact value of * using developer tool.
Thanks for quick response.
I have tried with your solution but the xpath is not working and give the nosuchelementexception. Because in the HTML Dom there are 2 iframe. Inside child frame we goto mouse over then it's visible . We mouse down then it is disapper. So my question is how to pause the mouse over section at certain time period so that all text are like 3m,6m,YTD,1y,All are visible and click one by one
In the DOm first div tag then the sequence order like
,, then 3m is displayed .
Could you please provide me the alternative solution?
I am using a button to transit to another layer. But I can't transit to that layer. I am using construct 3.
When I click on that button
onTouched an object (the object is that button) -> Go to layer (Layer02)
But nothing happens. I am using Touch but I have set the mouse input on. I used other object to try such as text field, and it works. Everything works except when I used button.
Is it a bug? Or I am not doing it right. The variables you see in the picture are for debugging purposes.
These are my events:
I think you refer to "transit to another layout" (not layer) 😉
On your screenshot I see all your events are OK. If you add Touch doesn't need add Mouse (you can use the mouse to simulate touch on browser).
I create a new project with the same events and works correctly, I attach a .c3p so you can try it. 😌
https://www.dropbox.com/s/7x1r27rs5a6k5d0/button_layout.c3p?dl=0
I am working on Protractor tests. Recently my web page changed where the terms and conditions are inside a textbox. Button Submit works only when the user scrolls through the textbox and clicks on Agree button. I tried the following option to scroll down but it is not scrolling down. Any help is greatly appreciated.
var scrollbar = element(by.id('terms-conditions'));
var checkbox = element(by.id('checkbox'));
scrollbar.click()
browser.executeScript('arguments[0].scrollIntoView()', scrollbar.getWebElement());
browser.executeScript('window.scrollTo(0,670);')
checkbox.click();
I followed the below link too but no luck.
Protractor: Scroll down
The second js execute statement you are using contains Window.scrollTo which references an open window in a browser. and using it only scrolls the complete window but not the pop-ups that appear inside a browser window
Refer here for documentation on Window.scrollTo
Normally terms and conditions shows up in a pop-up or may be a div and hence Window.scrollTo doesn't work
there are two ways you can do it
SOLUTION 1: use Jquery scrollTop() to scroll inside a specific webElement
Step 1: Identify the exact div that holds your terms of Service scroll bar
Step 2: Refine your js statement by trying directly in Chrome console
$('.modal-body').scrollTop() -> This returns the current position of scroll
$('.modal-body').scrollTop(10000) -> This sets the value of top position
Step 3: Incorporate this in your protractor script
browser.executeScript('$('.modal-body').scrollTop(10000)');
You can professionalize this by passing the element & scroll amount as arguments. Refer here
SOLUTION 2; The best way I see to submit a pop-up is not to deal with interface but to deal with the 'form' element behind it. Similar to how we deal with file uploads.No fuss & effective
May be try something like this, by making button visible first and then submit form
browser.executeScript is an asynchronous call, so you will need to put it into the controlFlow so that it will complete before clicking the checkbox:
scrollbar.click();
browser.controlFlow().execute(function() {
browser.executeScript('arguments[0].scrollIntoView()', scrollbar.getWebElement());
browser.executeScript('window.scrollTo(0,670);');
});
checkbox.click();