简体   繁体   中英

driver.setLocation() not working on iOS appium simulator

I have done a lot of searching online and I'm not sure what I'm doing wrong. The idea is that I want to launch my iOS app with the following location in a simulator. This works fine when I manually go to debug>location>custom location and set the longitude and latitude....however I need to do it programatically so that my app launches /picks up this location when I click enable locations. Here is my code

public class SampleTest extends SampleBaseTest {

          private IOSDriver driver;
          private String sessionId;
          static UserData sampleUser = null;


          @Test(priority = 0)
          public void setUp() throws MalformedURLException {

              DesiredCapabilities caps = DesiredCapabilities.iphone();
              caps.setCapability("appiumVersion", "1.4.16");
              caps.setCapability("deviceName","iPhone 6");
              caps.setCapability("deviceOrientation", "portrait");
              caps.setCapability("platformVersion","9.1");
              caps.setCapability("platformName", "iOS");
              caps.setCapability("browserName", "");
              caps.setCapability("app","sauce-storage:sampleAppe.zip");

            URL sauceUrl = new URL("http://" + "sauceUserName" + ":"+ "sauceUserKey" + "@ondemand.saucelabs.com:80/wd/hub");

            driver = new IOSDriver(sauceUrl, caps);
            Location location = new Location(-8.78319, -114.509, 0.0);
            driver.setLocation(location);

            sessionId = driver.getSessionId().toString();



          @Test(priority = 1)
          public void navigateToPayAhead()
                          throws Exception {

              try{
                    // test logic here

              }
              catch(Exception e){
                  e.printStackTrace();
              }

          }
        }
    }

Unfortunately, there is a current issue with setting a location on the Sauce iOS simulators. From a support ticket on a similar issue, I was told that it is a known issue, and that it will be addressed (at some point).

I can verify that setting a location does work when using the Android emulators via Sauce Labs.

So, I guess the good news is that you aren't doing anything wrong!

Try adding

caps.setCapability("locationServicesEnabled", true);
caps.setCapability("locationServicesAuthorized", true);
caps.setCapability("bundleId", "YOUR_BUNDLE_ID_HERE");

To get your bundle id, see How to obtain Bundle ID for an IOS App when I have a '.ipa' file for the app installed on my iPAD

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM