简体   繁体   English

driver.setLocation()在iOS appium模拟器上不起作用

[英]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. 我的想法是我想在模拟器中的以下位置启动我的iOS应用。 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. 不幸的是,在Sauce iOS模拟器上设置位置存在当前问题。 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. 通过Sauce Labs使用Android模拟器时,我可以确认设置位置确实可行。

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 要获取您的捆绑包ID,请参阅在iPAD上安装该应用程序的'.ipa'文件时如何获取IOS应用程序的捆绑包ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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