Tips for starting Safari using SafariLauncher on an actual iPhone

After following the tutorial on , I managed to create a project. However, I am now facing difficulties in finding a tutorial for running Appium with a web page. I have made edits to customize it according to my needs, for example, launching google.com which works fine on the emulator.

I have successfully installed SafariLauncher on my device and manually clicking the app works without any issues.

But when I try to use SafariLauncher with Appium, it fails to work as expected.

The console is showing the following information:

info: [debug] Attempting to run app on real device with UDID 5343fa7f9c04cb60f02cb40f1233073d23dbbbc7
... (console output continues)

And here is a snippet of my code:

// Relevant code snippet

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability("appium-version", "1.3.1");
... (code snippet continued)

In conclusion, I am struggling to make SafariLauncher work on a real device. Any help or guidance would be greatly appreciated!

Answer №1

If you're looking to execute tests using the Safari browser, simply ensure that you set the browser name capability:

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("appium-version", "1.3.1");
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("deviceName", "Tahir's iPhone");
capabilities.setCapability("udid", "your_udid");
capabilities.setCapability("bundleId", bundle);
capabilities.setCapability("browserName", "safari");
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);    

driver.get("http://www.google.com");
Thread.sleep(20000);

You can omit other SafariLauncher settings if your goal is solely to use Safari on a real phone.

The provided SafariTest example code from Saucelabs demonstrates this approach:

https://github.com/appium/sample-code/blob/master/sample-code/examples/java/junit/src/test/java/com/saucelabs/appium/SafariTest.java

Answer №2

It is recommended to utilize XCUITest for launching Safari rather than SafariLauncher

  1. Software Requirements

    Currently, two essential pieces of software are required to execute iOS tests on actual devices:

    • libimobiledevice - can be installed using
      brew install libimobiledevice
      --HEAD
    • ios-deploy - installation can be done with npm install -g ios-deploy
  2. Configuring WebDriverAgentRunner on a real device as per the documentation

  3. Include desired capabilities configuration in the source code as shown below:

platformName: "iOS",
platformVersion: "10.3",
deviceName: "HCiPhone",
browserName: "safari",
udid: "5343fa7f9c04cb60f02cb40f1233073d23dbbbc7",
startIWDP: true,
safariInitialUrl: "https://stackoverflow.com/"

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Counting the occurrences of a text in a webpage using Selenium WebDriver

Hey there! I'm trying to figure out how many times the text "VIM LIQUID MARATHI" appears on a specific page using selenium webdriver in Java. Can anyone assist me with this? In my main class, I've used the following code snippet to check if the ...

Steps to verify the element's placement on the list (Ensure it is indeed the top element on the list)

Still learning the ropes here. I am attempting to confirm that elements are arranged in descending order with the latest date being first (2019, 2018, 2017, 2016, etc). Below are the elements along with their corresponding dates: --> 2017/2018 --> 2016/ ...

Utilizing a Distinctive Profile in Selenium: A Step-by-

I am currently attempting to utilize a specific Profile within my Chrome Browser. To do so, I am aware that I must utilize the user-data-dir flag and specify the path to my desired Profile. For instance, let's assume I have a Profile named Profile 1 ...

Generating random user IDs and populating them into a text box using Selenium and Java

For the application I'm working on, I have to create new users frequently. I need a code snippet that can generate usernames using regular expressions. For example, "Alen001", "Alen002", "Alen003" and so forth. driver.findElement(By.id("userId")).sen ...

Tips for Combining Chrome driver service with desired capabilities for headless mode using xvfb?

I am looking to combine the functionalities of ChromeDriverService with either chromeOptions or DesiredCapabilities in order to run the browser in xvfb. Below is a snippet of code related to ChromeDriverService that I had previously used without selenium ...

Troubleshooting problem with input fields in Protractor due to sendKeys malfunction

My current task involves automating end-to-end tests using Protractor on an Angular application. However, I've encountered an issue with sending keys to input fields. The sendKeys function consistently misses a few characters each time it is used, so ...

What is the best approach to implement an explicit wait in Selenium using this code snippet?

Struggling to grab the correct image URLs and save them as jpgs after clicking on specific links. Instead of getting the desired image URL, I keep retrieving the URL of the page before it. The script is saving jpg files with timestamps, but they are empty ...

Is it possible to transmit messages from a Chrome extension to a Java server?

My question is, if I want to create a Chrome extension that sends messages to a Java server, should I use the XmlHttpRequest API in the extension and have the Java server as an HTTP server? ...

Creating simple Java programs utilizing the Selenium WebDriver

As a beginner Java programmer looking to familiarize myself with Selenium libraries, I have been searching Google for a good resource to learn basic Selenium programming. Despite my efforts, I have not been able to find the right place to start. Can anyone ...

Encourage your Facebook friends to join the app using either Objective C or PHP!

While this question may have been asked in the past, I am curious to know if there have been any new developments in Facebook's API that would allow for specific functionalities. Is it feasible (with permission from Facebook) for a user to programmat ...

Searching for the #document element using Python with Selenium WebDriver

While working with Python's Selenium Webdriver, I encountered a challenge when trying to access elements within an #document tag using the following HTML code. I attempted both driver.find_element_by_xpath("html/body/div[@id='frame']/ifram ...

Is there a way to execute automated selenium tests using TFS build 2015?

My NUnit selenium tests are integrated into Unit test and they work perfectly fine when run locally, but not on the TFS Server. After enabling code coverage, I noticed that "Module unittests.dll" was covering most of the code, while "Seleniumtest.exe" had ...

Unable to physically tap on the checkbox input, though able to perceive the value it holds

When running my protractor test, I encountered an issue with the following statement: await element(by.model('publishCtrl.isPublishedInAllRegions')).click(); The test failed and returned an error message stating "ElementNotVisibleError: element ...

How to execute an executable file using Java on a Mac computer

Currently, my objective is to launch a server using bash, and I've already crafted an UNIX shell script for this purpose. However, I'm encountering difficulties in executing it through Java within Eclipse. Below is the code snippet that I attemp ...

Having trouble with missing quotes in Swift when making a REST POST request

Struggling with a seemingly simple REST call that has left me completely stuck. I have a node-based restful service that requires an array of strings as input. However, every time I make the call with what seems like a valid parameter, the server throws an ...

Python's Selenium 4 does not support the Edge headless option set to True, only to False

I am working on a function that extracts information from a specific webpage (; focusing on ratings). I have recently set up selenium 4 along with webdriver_manager to manage the drivers efficiently. However, I encountered an issue when utilizing the head ...

How to execute a java class method within a JSP page

Is there a way to trigger a specific Java method when I click a button on a JSP page? I attempted using a scriptlet in the onclick event of the button to create an instance of the class and call the desired method, but unfortunately, it didn't yield t ...

Is there a dependable resource for mastering Protractor along with the Jasmine Framework in Eclipse using JavaScript?

Starting a new role at my organization where I will be testing Angular JS applications. Can anyone recommend a good website for learning PROTRACTOR with JAVASCRIPT using the JASMINE Framework? (Would prefer if it includes guidance on Eclipse IDE) Thank yo ...

Tips for locating the span element using XPath in the Google Chrome Developer Tools:

I'm attempting to locate the following HTML code: <span data-login="true" class="button-tab-links--gray hide-for-medium-only"> Olá, Visitante</span> using //span[@class="button-tab-links--gray hide-for-medium-only"] in Google Chrome t ...

Learn the step-by-step process of converting a string to JSON or object in Java 17

Is there a way in Java 17 to convert the string shown below into JSON format or an object? {name=sachin, style=short, country=india} ...