ericmckean / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

drag_and_drop_by_offset seems not working in selenium-2.35.0-py2.7 #525

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Before filing an issue, please read the page at
http://code.google.com/p/selenium/wiki/SeleniumHelp This contains lot of
information about how best to get help, and tells you what we need to know.

Still here? We know that bugs are frustrating and annoying things. We also
know that you've probably spent ages trying to figure out what's wrong. The
more information you give us now, the more likely it is that we'll be able
to help.

What steps will reproduce the problem?
1.run script :
  print self.current_element
  action_chains.drag_and_drop_by_offset(self.current_element, 330.5, 280).perform()
2.see the console outputs:
<selenium.webdriver.remote.webelement.WebElement object at 0x02B6F810>

======================================================================
ERROR: testSequencingWordVertical (__main__.TestActivityPage)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\eclipse\workspace2\SchoolAutomation\src\tests\unit_test\activity_page_test.py", line 349, in testSequencingWordVertical
    [atcp.perform_actions(a,q) for (q,a) in sorted_questions_answers_pair]
  File "D:\eclipse\workspace2\SchoolAutomation\src\common\page_object.py", line 414, in perform_actions
    self.tag_map_function[tag_name](*arguments_for_xpath)
  File "D:\eclipse\workspace2\SchoolAutomation\src\common\page_object.py", line 41, in wrapper
    return func(*args, **kwargs)
  File "D:\eclipse\workspace2\SchoolAutomation\src\common\page_object.py", line 291, in handle_drag_drop_operation
    r.perform()
  File "C:\Python27\lib\site-packages\selenium-2.35.0-py2.7.egg\selenium\webdriver\common\action_chains.py", line 44, in perform
    action()
  File "C:\Python27\lib\site-packages\selenium-2.35.0-py2.7.egg\selenium\webdriver\common\action_chains.py", line 192, in <lambda>
    'yoffset': yoffset}))
  File "C:\Python27\lib\site-packages\selenium-2.35.0-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 165, in execute
    self.error_handler.check_response(response)
  File "C:\Python27\lib\site-packages\selenium-2.35.0-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 164, in check_response
    raise exception_class(message, screen, stacktrace)
WebDriverException: Message: u'unknown error: at least an element or offset 
should be set\n  (Session info: chrome=29.0.1547.66)\n  (Driver info: 
chromedriver=2.2,platform=Windows NT 6.1 SP1 x86_64)' 

3.

What is the expected output? What do you see instead?

Selenium version:2.35.0-py2.7
OS:window 7
Browser:chrome
Browser version:Version 29.0.1547.66 m

Please provide any additional information below. A sample reduced test
case, or a public URL that demonstrates the problem will intrigue our merry
band of Open Source developers far more than nothing at all: they'll be far
more likely to look at your problem if you make it easy for them!

Original issue reported on code.google.com by chester....@gmail.com on 7 Sep 2013 at 5:19

GoogleCodeExporter commented 9 years ago
Issue 6227 has been merged into this issue.

Original comment by a.u.savchuk on 7 Sep 2013 at 5:17

GoogleCodeExporter commented 9 years ago
Hi!

Please provide executable test script
and public URL or HTML+CSS+JS of page at which the problem is reproduced.

Original comment by a.u.savchuk on 7 Sep 2013 at 5:20

GoogleCodeExporter commented 9 years ago

Original comment by a.u.savchuk on 7 Sep 2013 at 5:20

GoogleCodeExporter commented 9 years ago
ok

Original comment by chester....@gmail.com on 8 Sep 2013 at 4:10

GoogleCodeExporter commented 9 years ago
Hi avchuk,
Here is the runnable script and public url within, may be will help you a 
little!

import unittest

from selenium.webdriver.chrome.webdriver import WebDriver

from selenium.webdriver.common.action_chains import ActionChains 

from selenium.webdriver.support.ui import WebDriverWait

TEST_ACCOUNTS = [('cuat2','111111','uat')]
TIME_OUT_FOR_GET_ELEMENT = 20

class Global:
    SESSION = {"current_domain_name":''}

    class Environment:
        SCHOOL_UAT = 'schooluat.englishtown.com'

class TestDragDropByOffSet(unittest.TestCase):
    def setUp(self):
        self.main_url = "http://%s/online/member/login2?lng=en"
        self.activity_url = "http://schooluat.englishtown.com/school/e12?debug=p=2sca&ctr=fr&lng=en#school/78107/396/570/2179/9200/41108/123032"
        self.web_driver = WebDriver()

    def tearDown(self):
        self.web_driver.quit()
        pass

    def get_element(self, xpath, timeout=TIME_OUT_FOR_GET_ELEMENT):
        find_element_expression = lambda x:x.find_element_by_xpath(xpath)

        element = WebDriverWait(self.web_driver, timeout).until(find_element_expression) 

        return element

    def test(self):
        self.web_driver.get(self.main_url%Global.Environment.SCHOOL_UAT)
        LOGIN_USER_NAME = self.get_element("//input[@id='UserName']")
        LOGIN_PASSWORD = self.get_element("//input[@id='Password']")
        LOGIN_SUBMIT_BUTTON = self.get_element("//a[contains(@class,'et-btn-submit')]")

        LOGIN_USER_NAME.send_keys('cuat2')
        LOGIN_PASSWORD.send_keys('111111')
        LOGIN_SUBMIT_BUTTON.click()

        self.web_driver.get(self.activity_url)

        answer = self.get_element("//ul[@class='ets-act-swv-list ui-sortable']/li[@id='%s']"%'w_4')
        question = self.get_element("//ul[@class='ets-act-swv-list ui-sortable']/li[@data-position='%s']"%5)

        action_chains = ActionChains(self.web_driver)
        action_chains.drag_and_drop_by_offset(answer, question.location['x'], question.location['y']).perform()
        assert 0
        pass

def suite():
    suite = unittest.TestSuite()
    for i in range(1):
        suite.addTest(TestDragDropByOffSet('test'))   
    return suite

if __name__ == '__main__':
    unittest.main(defaultTest='suite')  

Original comment by chester....@gmail.com on 8 Sep 2013 at 5:38

GoogleCodeExporter commented 9 years ago
Hi!

I can not reproduce it for my Win7, selenium 2.35, chromedriver 2.3, chrome 29.
Could you recheck it with the latest chromedriver?

Also please provide exception for example from #c5

Original comment by a.u.savchuk on 9 Sep 2013 at 10:52

GoogleCodeExporter commented 9 years ago
Hi, but it's still not working on my side ( Win7, selenium 2.35, chromedriver 
2.3, chrome 29)
The exception:
E
======================================================================
ERROR: test (__main__.TestDragDropByOffSet)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\eclipse\workspace2\SchoolAutomation\src\common\test.py", line 51, in test
    action_chains.drag_and_drop_by_offset(answer, question.location['x'], question.location['y']).perform()
  File "C:\Python27\lib\site-packages\selenium-2.35.0-py2.7.egg\selenium\webdriver\common\action_chains.py", line 44, in perform
    action()
  File "C:\Python27\lib\site-packages\selenium-2.35.0-py2.7.egg\selenium\webdriver\common\action_chains.py", line 192, in <lambda>
    'yoffset': yoffset}))
  File "C:\Python27\lib\site-packages\selenium-2.35.0-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 165, in execute
    self.error_handler.check_response(response)
  File "C:\Python27\lib\site-packages\selenium-2.35.0-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 164, in check_response
    raise exception_class(message, screen, stacktrace)
WebDriverException: Message: u'unknown error: at least an element or offset 
should be set\n  (Session info: chrome=29.0.1547.66)\n  (Driver info: 
chromedriver=2.3,platform=Windows NT 6.1 SP1 x86_64)' 

----------------------------------------------------------------------
Ran 1 test in 23.016s

FAILED (errors=1)

Original comment by chester....@gmail.com on 9 Sep 2013 at 12:06

GoogleCodeExporter commented 9 years ago
Hi!

The error "at least an element or offset should be set" is raised when 
chromedriver receives no "xoffset" or "yoffset" JSON parameter.

Could you check what question.location contains before executing of line:

action_chains.drag_and_drop_by_offset(answer, question.location['x'], 
question.location['y']).perform()

?

Also it'd be good if you investigate what JSON string python binding sends to 
chromedriver.

Original comment by a.u.savchuk on 10 Sep 2013 at 12:28

GoogleCodeExporter commented 9 years ago
hi about what  contains in question.location from #c5:
print answer
print question
print question.location['x'] 
print question.location['y']
print type(question.location['x'])
print type(question.location['y'])

outputs:
<selenium.webdriver.remote.webelement.WebElement object at 0x02AAAEF0>
<selenium.webdriver.remote.webelement.WebElement object at 0x02AAAFB0>
327.5
430
<type 'float'>
<type 'int'>

Original comment by chester....@gmail.com on 11 Sep 2013 at 1:54

GoogleCodeExporter commented 9 years ago
The json string:

request1:
http://127.0.0.1:21172/session/36af2540235e84cd68752fdf51e45858/element/0.255741
33172631264-2/location

json1:
JSON
    sessionId=36af2540235e84cd68752fdf51e45858
    status=0
    value
        toString
        x=327.5
        y=482
================================================================================
=====================
request2:
http://127.0.0.1:21172/session/36af2540235e84cd68752fdf51e45858/moveto

json2:
JSON
    sessionId=36af2540235e84cd68752fdf51e45858
    status=0
    value=(null)
================================================================================
======================
request3:
http://127.0.0.1:21172/session/36af2540235e84cd68752fdf51e45858/buttondown

json3:
JSON
    sessionId=36af2540235e84cd68752fdf51e45858
    status=0
    value=(null)
================================================================================
======================
request4:
http://127.0.0.1:21172/session/36af2540235e84cd68752fdf51e45858/moveto

json4:
JSON
    sessionId=36af2540235e84cd68752fdf51e45858
    status=13
    message=unknown error: at least an element or offset should be set
  (Session info: chrome=29.0.1547.66)
  (Driver info: chromedriver=2.3,platform=Windows NT 6.1 SP1 x86_64)

Original comment by chester....@gmail.com on 11 Sep 2013 at 2:13

GoogleCodeExporter commented 9 years ago
Reproduced.

The problem is with float coordinate - chromedriver accepts only integers now.
Force converting was enabled in Python and Ruby bindings at rfc395f18551d

Original comment by a.u.savchuk on 12 Sep 2013 at 12:04

GoogleCodeExporter commented 9 years ago
You could make force converting manually by:

question.location['x'] = int(question.location['x'])

as workaround.

Original comment by a.u.savchuk on 12 Sep 2013 at 12:05

GoogleCodeExporter commented 9 years ago
hi, savchuk
That's great for me, thanks a lot !

Original comment by chester....@gmail.com on 12 Sep 2013 at 12:37

GoogleCodeExporter commented 9 years ago

Original comment by kkania@chromium.org on 30 Sep 2013 at 10:52

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 21 Feb 2015 at 12:19