Appium [MAC] [iOS] Bad pp error - testing

I have an error when trying to launch iOS app by desktop Appium server, i managed to run the test on android device successfully, but failed to do the same for the iOS.
The error is:
>
Bad app: >/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/app>ium-ios-driver/build/SafariLauncher/SafariLauncher.app. App paths need to be >absolute, or relative to the appium server install dir, or a URL to compressed >file, or a special app name.
My code is:
// Set desired capabilities.
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "iOS");
// REAL DEVICE
//capabilities.setCapability("deviceName", "iPhone 6s");
capabilities.setCapability("deviceName", "Testing iPhone6s");
capabilities.setCapability("platformVersion", "11.0.1");
capabilities.setCapability("browserName", "Safari");
capabilities.setCapability("orientation", "PORTRAIT");
capabilities.setCapability("udid", "XXXX");
String apkpath="/Users/testing/Desktop/Mohandisi.ipa";
// capabilities.setCapability(MobileCapabilityType.APP, apkpath);
File app=new File(apkpath);
capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
// Open the app.
driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
I don't know why appium days that the application is bad although i added the full path!
iOS Settings in Appium Server Screen shot

Related

Error: The specified executable path does not exist: /tmp/.mount_JobAppuO0ICL/resources/app.asar/dist/main/chromedriver/chromedriver

I am trying to use Selenium and Chrome WebDriver in Electron, which works fine in development. However, once I package the application and run it, I get the following error:
Error: The specified executable path does not exist: /tmp/.mount_JobAppuO0ICL/resources/app.asar/dist/main/chromedriver/chromedriver
Here's the code that starts the driver:
const service = new chrome.ServiceBuilder(path).build();
chrome.setDefaultService(service);
const options = new chrome.Options();
options.options_.debuggerAddress = "localhost:9222";
this.driver = await new Builder()
.withCapabilities({ unexpectedAlertBehaviour: "accept" })
.forBrowser("chrome")
.setChromeOptions(options)
.build();
Where path is from require("chromedriver").path.
I'm not using selenium and chrome driver to test Electron app. I'm using selenium and chrome driver for functionality inside Electron app.
Thank you

How to remove the infobar "Microsoft Edge is being controlled by automated test software" in selenium test

We are using selenium to run test against "Chromium based Edge".
"The Chromium Edge" is downloaded from https://www.microsoftedgeinsider.com/en-us/download and the version is 80.0.334.2 (Official build) dev (64-bit).
We got the matched driver msedgedriver.exe from https://msedgewebdriverstorage.z22.web.core.windows.net/
We add the "C:\Program Files (x86)\Microsoft\Edge Dev\Application" to the environment "PATH" so that the executable "msedge.exe" will be found during the test.
After starting the selenium server with option -Dwebdriver.edge.driver="pathTo\msedgedriver.exe", we can get the test run in the "Chromium Edge" as below:
But there is a infobar "Microsoft Edge is being controlled by automated test software", just like we run test with chrome browser. With chrome, we can remove that infobar by setting the following ExperimentalOption to ChromeOptions
useAutomationExtension=false
excludeSwitches=[enable-automation]
prefs={credentials_enable_service=false, profile={password_manager_enabled=false}}
I tried to set the same options and I got a browser launched without the infobar, but it is a chrome browser NOT the "Chromium Edge".
You could refer to the following code (C# code) to set the chrome options and remove the infobar.
var edgechromiumService = ChromeDriverService.CreateDefaultService(#"E:\edgedriver_win64", "msedgedriver.exe");
// user need to pass the driver path here....
ChromeOptions edgechromeOptions = new ChromeOptions
{
BinaryLocation = #"C:\Program Files (x86)\Microsoft\Edge Dev\Application\msedge.exe",
};
edgechromeOptions.AddAdditionalCapability("useAutomationExtension", false);
edgechromeOptions.AddExcludedArgument("enable-automation");
using (IWebDriver driver = new ChromeDriver(edgechromiumService, edgechromeOptions))
{
driver.Navigate().GoToUrl("https://www.bing.com/");
Console.WriteLine(driver.Title.ToString());
//driver.Close();
Console.ReadKey();
}
The result like this:
For Java applications, please try to use the following code:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeOptions;
import java.util.*;
public class Edgeauto {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "your\\path\\to\\edge\\webdriver\\msedgedriver.exe");
ChromeOptionschromeOptions = new ChromeOptions();
chromeOptions.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe");
chromeOptions.setExperimentalOption("useAutomationExtension", false);
chromeOptions.setExperimentalOption("excludeSwitches",Collections.singletonList("enable-automation"));
EdgeOptions edgeOptions = new EdgeOptions().merge(chromeOptions);
WebDriver driver = new ChromeDriver(edgeOptions);
driver.get("https://www.google.com/");
}
}
I think that I can explain the all the confusions (perhaps for myself 😊). In the following link Microsoft Chromium Edge
We can find something as below:
If you were previously automating or testing Microsoft Edge (Chromium) by using ChromeDriver and ChromeOptions, your WebDriver code will not run successfully against Microsoft Edge 80 or later. This is a breaking change and Microsoft Edge (Chromium) no longer accepts these commands. You must change your tests to use EdgeOptions and Microsoft Edge Driver.
So we can handle the Chromium-Edge (version is smaller than 80) completely as a chrome browser.
System.setProperty("webdriver.chrome.driver", "C:\\SeleniumPlus\\extra\\msedgedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe");
chromeOptions.setExperimentalOption("useAutomationExtension", false);
chromeOptions.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
ChromeDriver driver = new ChromeDriver(chromeOptions);
driver.get("http://www.google.com");
driver.close();
For the Chromium-Edge (version 80 or later), we should treat it as an Edge browser, the code is as below:
The problem is that EdgeOptions does NOT provide enough APIs (setBinary, setExperimentalOption) as ChromeOptions ☹.
I checked the selenium’s source code at github and I found that the EdgeOptions has already supported those methods as ChromeOptions. So I downloaded the latest official build whose version is 3.141.59, and it was released this on Dec 20, 2018 and I found out that it doesn’t contain the latest source code ☹.
So I got the alpha release 4.0.0-alpha-4 and it does contain the latest source code.
System.setProperty("webdriver.edge.driver", "C:\\SeleniumPlus\\extra\\msedgedriver.exe");
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe");
edgeOptions.setExperimentalOption("useAutomationExtension", false);
edgeOptions.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
EdgeDriver driver = new EdgeDriver(edgeOptions);
driver.get("http://www.google.com");
driver.close();
Finally I want to thank my comrade comrade Carl, he helped me find the trick.
You saw it right.
As per the article Microsoft’s Edge Chromium browser will launch on January 15th with a new logo Microsoft is planning to release its Edge Chromium browser on January 15th 2020 with availability for Windows 10, Windows 7, Windows 8, and macOS. This came just after Microsoft released the beta version of Edge.
Now, this Beta also means that Microsoft is edging closer to the release stage for its Chromium browser. Microsoft first released its Canary and Developer builds of Edge back in April, and the company has spent the past four months working alongside Google to improve Chromium for Windows. That work also involved Microsoft getting used to the cadence of delivering a Chromium browser.
Hence adding the ExperimentalOption you see the Microsoft’s Edge Chromium browser almost like a Chromium / Chrome browser.
#Zhi Lv - MSFT
What is the browser you are launching? Chrome or Chromium-Edge? I am using selenium java code, if I run the similar java code as below, it will fail with error
The path to the driver executable must be set by the webdriver.chrome.driver system property;
System.setProperty("webdriver.edge.driver", "C:\\SeleniumPlus\\extra\\msedgedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe");
chromeOptions.setExperimentalOption("useAutomationExtension", false);
chromeOptions.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("http://www.google.com");
If I create an edge capabilities and merge the ChromeOption into it, I can see that "Chromium-Edge" gets started without the "infobar", but it just gets stuck there and fails with an error
unknown error: unrecognized Chrome version: Edg/80.0.361.5
System.setProperty("webdriver.edge.driver", "C:\\SeleniumPlus\\extra\\msedgedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe");
chromeOptions.setExperimentalOption("useAutomationExtension", false);
chromeOptions.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
DesiredCapabilities m_capability = DesiredCapabilities.edge();
m_capability.merge(chromeOptions);
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), m_capability);
driver.get("http://www.google.com");
From the "selenium server" console, I can see, the "browserName" is "chrome", I guess that is the reason why chrome's options is working to get rid of the "infobar"
15:37:55.502 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"goog:chromeOptions": {
"args": [
],
"binary": "C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe",
"excludeSwitches": [
"enable-automation"
],
"extensions": [
],
"useAutomationExtension": false
},
"platform": "WINDOWS",
"version": ""
}
If I set the "browserName" to "MicrosoftEdge" after merging the chrome's options as below, it can get the "Chromium-Edge" started, but the chrome's options do not work any more, which means the "infobar" is still there.
m_capability.merge(chromeOptions);
m_capability.setCapability(CapabilityType.BROWSER_NAME, BrowserType.EDGE);

appium css selector is not supported for this session

While using appium through desktop app, with interface, setting all ports manually it works perfectly, but when I try to launch using cmd:
"C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\appium\build\lib\main.js" --address 127.0.0.1 --port 4279 --chromedriver-port 9516 --bootstrap-port 4725 --selendroid-port 8082 --no-reset --local-timezone
my code is:
DesiredCapabilities cap = new DesiredCapabilities();
cap.SetCapability("deviceName", "Snapchat");
cap.SetCapability("platformVersion", "5.1.1");
cap.SetCapability("platformName", "Android");
cap.SetCapability("appPackage", "com.snapchat.android");
cap.SetCapability("appActivity", "com.snapchat.android.app.main.activity.LoginAndSignupActivity");
AndroidDriver<AndroidElement> driver;
driver = new AndroidDriver<AndroidElement>(new Uri("http://127.0.0.1:4279/wd/hub"), cap);
Thread.Sleep(5000);
driver.FindElement(By.Id("com.snapchat.android:id/login_and_signup_page_fragment_login_button")).Click();
Thread.Sleep(5000);
It fails with 'css selector' is not supported for this session
error. How to solve this problem?
Please try replacing
from selenium import webdriver
with this one:
from appium import webdriver
Usually for native app, there is no CSS selector. Only for hybrid app, there will be . So people use class name,Id,name or xpath to identify elements Or If you have webview in you application like clicking help page redirects to website link, then you can use css selector

How to handle downloading popup alert, while downloading a file in chrome

Point 1. If I launched normal chrome driver without loading any profile then it would block all exe (keep/discard)
Point 2. When I provided my chrome profile, these are my observations:
Clean exe downloading normally
Download error exe giving same dialogue on chrome driver as normally on chrome browser
Issue is here: those exe which are througing alert of keep/decline popup normally ...those are normally downloading on driver.
SNAPSHOT attached (http://i.stack.imgur.com/PtZ18.png)
I am loading chrome profile by this pattern
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir="+userProfile);
options.addArguments("--start-maximized");
options.addArguments("test-type");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(options);
So this is the main Issue
One more thing: Actually these popups are not html pages. These are over layer on chrome so any technique to spy those using any other free tool? or selenium?
Try this maybe
((JavascriptExecutor) driver).executeScript("window.confirm = function(msg) { return true; }");

org.openqa.selenium.WebDriverException: Unknown command: uploadFile

I am trying to upload a file using Safari Driver.
Here is my code:
DesiredCapabilities browserCapabillities = DesiredCapabilities.safari();
RemoteWebDriver driver = new SafariDriver(browserCapabillities);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("myAppURL");
WebElement upload = driver.findElementByXPath("//input[#id='fileElementId']");
RemoteWebElement webElement = ((RemoteWebElement) upload);
LocalFileDetector detector = new LocalFileDetector();
webElement.setFileDetector(detector);
File f = detector.getLocalFile("myFilePath");
upload.sendKeys(f.getAbsolutePath()); // Generating exception:
// org.openqa.selenium.WebDriverException: Unknown command: uploadFile
driver.findElement(By.id("uploadButton")).click();
Only thing that is working for me right now is AppleScript. Thanks to Using AppleScript to choose a file in Safari. But with Apple Script I had to keep my machine unlocked.
I feel LocalFileDetector is a better solution as I would like to run my tests even when the machine is locked.
I am not sure whether the following helps ?
driver.setFileDetector(new LocalFileDetector()); // I am getting
// org.openqa.selenium.WebDriverException: Setting the file detector only
// works on remote webdriver instances obtained via RemoteWebDriver
Change
RemoteWebDriver driver = new SafariDriver(browserCapabillities);
to
RemoteWebDriver driver = new RemoteWebDriver(urlofhub,browserCapabillities);
Refer this post for an example code.