Saturday, March 28, 2015

Workaround for broken 'safariIgnoreFraudWarning' Capability on XCODE Simulator via Appium

The Problem
While executing a Selenium test on an XCode simulator using Appium, you encounter the following screen:



To proceed beyond this point, you need to manually click 'Ignore this Warning'. Not good; defeats the purpose of automating your test.

This despite having explicitly instructed the Simulator to suppress the warning in the Desired Capabilites:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
self.DC = {
        'platformName' : 'iOS',
        'platformVersion' : '8.0',
        'deviceName' : 'iPhone 4s',
        'browserName' : 'Safari',
        'safariIgnoreFraudWarning' : 'True',
        'deviceOrientation': 'portrait'
}

self.appium_simulator = webdriver.Remote(command_executor='http://127.0.0.1:4723/wd/hub', desired_capabilities=self.DC)


The Solution
The "Possible Phishing Site" is a regular HTM page and therefore can be interacted with in the normal fashion. You just need to click that 'Ignore this Warning' button...


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
def possible_phishing_site(self):

    URL = "https://username:password@testurl.tld"
    self.appium_simulator.get(URL)
    time.sleep(5)

    #'Possible Phising Site' message...
    try:
        ITW = self.appium_simulator.find_element_by_css_selector("button#ignore_this_warning")
        if ITW:
            print "We are on the 'Possible Phising Page' in Safari"
            time.sleep(1)
            ITW.click()
            print "'Ignore this Warning' button clicked"
            time.sleep(5)
    except Exception as e:
        print "Exception:", str(e)
        print "'Possible Phising Page' not reachable via Selenium"




Job done.