Book Image

Learning Selenium Testing Tools - Third Edition

Book Image

Learning Selenium Testing Tools - Third Edition

Overview of this book

Table of Contents (22 chapters)
Learning Selenium Testing Tools Third Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using OperaDriver on Opera Mobile


To make sure that we have the right amount of coverage over the browsers that users may be using, there is a good chance that you will need to add Opera Mobile. Before starting, make sure that you have downloaded the version of the emulator for your Operating System with one of the links mentioned previously. Create a new test file. Add the following code to it:

import junit.framework.TestCase;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

public class TestChapter7OperaMobile{
  WebDriver driver;
}
  1. What we now need to do is add a setup method. We will have to add a couple of items to our DesiredCapabilities object. This will tell OperaDriver that we want to work against a mobile version. Refer to the following steps:

    @Before
    public void setUp(){
      DesiredCapabilities c = DesiredCapabilities.opera();
      c.setCapability("opera.product", OperaProduct.MOBILE);
      c.setCapability("opera.binary", "/path/to/my/custom/opera-mobile-build");
    ...