Skip to content

Commit

Permalink
Adding sample code snippets for scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
moizjv committed Apr 22, 2015
1 parent 6ff926b commit b3d035a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/en/writing-running-appium/appium-bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ execute_script "mobile: scrollTo", :element => element.ref

```python
# python
todo: python
driver.execute_script("mobile: scrollTo", {"element": element.id})
```

```java
Expand Down
65 changes: 61 additions & 4 deletions docs/en/writing-running-appium/touch-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,50 @@ To allow access to this special feature, we override the `execute` or
`executeScript` methods in the driver, and prefix the command with `mobile: `.
See examples below:

* **WD.js:**
To scroll, pass direction in which you intend to scroll as parameter.


```javascript
// javascript
// scroll the view down
driver.execute("mobile: scroll", [{direction: 'down'}])
// continue testing
```

* **Java:**
```java
// java
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "down");
js.executeScript("mobile: scroll", scrollObject);
```

```ruby
# ruby
execute_script 'mobile: scroll', direction: 'down'
```

```python
# python
driver.execute_script("mobile: scroll", {"direction": "down"})
```

```csharp
// c#
Dictionary<string, string> scrollObject = new Dictionary<string, string>();
scrollObject.Add("direction", "down");
((IJavaScriptExecutor)driver).ExecuteScript("mobile: scroll", scrollObject));
```

```php
$params = array(array('direction' => 'down'));
$driver->executeScript("mobile: scroll", $params);
```

Sample to scroll using direction and element.

```javascript
// javascript
driver.execute("mobile: scroll", [{direction: 'down', element: element.value}]);
```

```java
// java
Expand All @@ -124,6 +158,29 @@ scrollObject.put("element", ((RemoteWebElement) element).getId());
js.executeScript("mobile: scroll", scrollObject);
```

```ruby
# ruby
execute_script 'mobile: scroll', direction: 'down', element: element.ref
```

```python
# python
driver.execute_script("mobile: scroll", {"direction": "down", element: element.getAttribute("id")})
```

```csharp
// c#
Dictionary<string, string> scrollObject = new Dictionary<string, string>();
scrollObject.Add("direction", "down");
scrollObject.Add("element", <element_id>);
((IJavaScriptExecutor)driver).ExecuteScript("mobile: scroll", scrollObject));
```

```php
$params = array(array('direction' => 'down', 'element' => element.GetAttribute("id")));
$driver->executeScript("mobile: scroll", $params);
```

**Automating Sliders**


Expand Down

0 comments on commit b3d035a

Please sign in to comment.