Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(436)

Side by Side Diff: chrome/test/chromedriver/client/webelement.py

Issue 251933005: [ChromeDriver] Support mobile emulation on desktop Chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from command_executor import Command 5 from command_executor import Command
6 6
7 7
8 class WebElement(object): 8 class WebElement(object):
9 """Represents an HTML element.""" 9 """Represents an HTML element."""
10 def __init__(self, chromedriver, id_): 10 def __init__(self, chromedriver, id_):
11 self._chromedriver = chromedriver 11 self._chromedriver = chromedriver
12 self._id = id_ 12 self._id = id_
13 13
14 def _Execute(self, command, params=None): 14 def _Execute(self, command, params=None):
15 if params is None: 15 if params is None:
16 params = {} 16 params = {}
17 params['id'] = self._id; 17 params['id'] = self._id;
18 return self._chromedriver.ExecuteCommand(command, params) 18 return self._chromedriver.ExecuteCommand(command, params)
19 19
20 def FindElement(self, strategy, target): 20 def FindElement(self, strategy, target):
21 return self._Execute( 21 return self._Execute(
22 Command.FIND_CHILD_ELEMENT, {'using': strategy, 'value': target}) 22 Command.FIND_CHILD_ELEMENT, {'using': strategy, 'value': target})
23 23
24 def FindElements(self, strategy, target): 24 def FindElements(self, strategy, target):
25 return self._Execute( 25 return self._Execute(
26 Command.FIND_CHILD_ELEMENTS, {'using': strategy, 'value': target}) 26 Command.FIND_CHILD_ELEMENTS, {'using': strategy, 'value': target})
27 27
28 def GetText(self):
29 return self._Execute(
30 Command.GET_ELEMENT_TEXT)
stgao 2014/05/14 05:10:14 make it one line instead of two?
sam.rawlins 2014/05/16 21:09:38 Done.
31
28 def HoverOver(self): 32 def HoverOver(self):
29 self._Execute(Command.HOVER_OVER_ELEMENT) 33 self._Execute(Command.HOVER_OVER_ELEMENT)
30 34
31 def Click(self): 35 def Click(self):
32 self._Execute(Command.CLICK_ELEMENT) 36 self._Execute(Command.CLICK_ELEMENT)
33 37
34 def SingleTap(self): 38 def SingleTap(self):
35 self._Execute(Command.TOUCH_SINGLE_TAP) 39 self._Execute(Command.TOUCH_SINGLE_TAP)
36 40
37 def Clear(self): 41 def Clear(self):
38 self._Execute(Command.CLEAR_ELEMENT) 42 self._Execute(Command.CLEAR_ELEMENT)
39 43
40 def SendKeys(self, *values): 44 def SendKeys(self, *values):
41 typing = [] 45 typing = []
42 for value in values: 46 for value in values:
43 if isinstance(value, int): 47 if isinstance(value, int):
44 value = str(value) 48 value = str(value)
45 for i in range(len(value)): 49 for i in range(len(value)):
46 typing.append(value[i]) 50 typing.append(value[i])
47 self._Execute(Command.SEND_KEYS_TO_ELEMENT, {'value': typing}) 51 self._Execute(Command.SEND_KEYS_TO_ELEMENT, {'value': typing})
48 52
49 def GetLocation(self): 53 def GetLocation(self):
50 return self._Execute(Command.GET_ELEMENT_LOCATION) 54 return self._Execute(Command.GET_ELEMENT_LOCATION)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698