Showing posts with label Selenium. Show all posts
Showing posts with label Selenium. Show all posts

Thursday, 22 September 2016

Helper methods Appium 1.6.0 Beta

  // iOS        // Find element in table cell         driver.findElementByXPath("//XCUIElementTypeCell/XCUIElementTypeStaticText[@name='some-id']"));


        //   Print source of screen visible        System.out.println(driver.getPageSource());

        //default timeout for all commands executed using this driver. can be overridden using explicit wait        driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);

        //EXPLICIT wait for element for x seconds        //  If explicit wait > implicit wait , then greater driver will default to greater wait period        int seconds= 3;
        WebDriverWait wait = new WebDriverWait(driver, seconds);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("some-id")));

//        UIAutomation(IOS)//        Find visibility of element using XPath        xpath = "UIATableCell/UIAStaticText[@label='Family'][@visible='true']";
        driver.findElementByXPath(xpath);

        click on first table cell (xpath may change based on your application)
        xpath("//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[1]").click

2) Migration IOS Appium tests from UIAutomation to XCUITest

Most of the Elements have changed after Instruments have moved form UIAutomation to XCUITest
Hence all references using classnames and xpaths in Appium Automation must be updated to run from Appium 1.6.0 onwards
at the moment its in beta
Look at installation procedure here - http://mytechlifez.blogspot.co.uk/2016/09/appium-1.6.0-beta1-installation-xcode8-ios10.html

Table elements

Table / Row
UIATableview -> XCUIElementTypeTable
UItableviewcell -> XCUIElementTypeCell

Choose row 1 in a table using xpath- 
"///XCUIElementTypeTable[1]/XCUIElementTypeCell[1]/XCUIElementTypeStaticText[1]"
"//XCUIElementTypeCell[1]/XCUIElementTypeStaticText[1]"

XCUItest iOShttps://discuss.appium.io/t/appium-xcuitest-example-how-to-get-started-appium-using-xcuitest-for-real-device/12415/4//Migrating from UIAutomation to XCUItestUIAButton changes into  XCUIElementTypeButton
UIA***    --> XCUIElementType***
UIAStaticText -> XCUIElementTypeStaticText
UIATableView -> XCUIElementTypeTable
UIANavigationBar -> XCUIElementTypeNavigationBar

Buttons


"UIABUtton" is replaced by "XCUIElementTypeButton"

1) Appium 1.6.0 beta1 Installation

I have managed to run my IOS tests on XCUItest using below changes.
Elements have to migrated from UIA to XCUI elements

Inorder to run appium on 1.6.0 beta 1 for ios 10 and xcode 8
use below settings

[caps]
platformName = "iOS"
orientation = "PORTRAIT"
platformVersion = "10.0"
deviceName ="iPhone Simulator"
noReset = "false"
automationName = "xcuitest"
appiumVersion = "1.6.0-beta1"
app="<app_path>/<app_name>.app"
[appium_lib]

Installation

npm uninstall appium
npm install appium@1.6.0-beta1

npm install -g appium-xcuitest-driver
brew install carthage

Install carthage dependency manager

Error : Fetching dependencies\nPlease make sure that you have Carthage installed (https://github.com/Carthage/Carthage)\nNote: We are expecting that carthage installed in /usr/local/bin/\n',
Solution : brew install carthage








Xcode 8 Installation : 
download xcode
unzip the xcode file 
Rename old /Applications/Xcode.app to /Applications/Xcode7.app(incase you still want to keep it)
Drag new Xcode app to /Applications/Xcode.app
Open Xcode and install it 







Other fixes: 

If you encounter issues  check here - https://github.com/appium/appium/issues/6853
I had to manually run bootstrap as mentioned in above link 
cd ~/.npm-global/lib/node_modules/appium-xcuitest-driver/WebDriverAgent
sh Scripts/bootstrap.sh 


To Properly install node check this link - https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md





Monday, 6 May 2013

Simple steps to get ruby 1.9.3 for calabash on mac osx 10.7

I did face this problem of getting ruby 1.9.3 on mac osx 10.7
Then I realized I need rvm but before doing all this I did need xcode installed
this must be easy for mac experts not for me definitely

Here are simple steps for a mac beginner to get ruby 1.9.3

  • Download install xcode from appstore
  • Install command line tools from xcode - Go to xcode->preferences->downloads->components->commandline tools 
  • Install RVM
          \curl -#L https://get.rvm.io | bash -s stable --autolibs=3 --ruby
  • Install ruby using RVM - Install ruby 1.9.3 and use it
    rvm install 1.9.3
    rvm use 1.9.3
     

Errors & Solution

If there are error in RVM installation do this
Type following commands
~ $: source ~/.rvm/scripts/rvm
~ $: type rvm | head -n 1
rvm is a function
~ $: vi ~/.bash_profile add this line into bash_profile 
"source ~/.rvm/scripts/rvm"
Install ruby 1.9.3 and use it
 

Saturday, 6 October 2012

Selenium - Create CONFIG file and read it (java)

One of the challenges we face while creating test suite is to put common settings into a file and read it from code as and when neccessary. I did struggle a bit so thought sharing this might help any one who encounters similar problem.

Steps:

1) Create a file say in ur src folder or create a new package config and put a file called config.properties
2) From the file where you want to read create a varaiable like

public
static Properties CONFIG = new Properties();
3) Then load the content into it from the file you have created

FileInputStream fn = new
FileInputStream("path to project"+ \\src\\configure\\config.properties);

CONFIG
.load(fn);

4) Put a value into file config.properties which has to be read 
ex:
#url
mainsite=http://www.rediff.com

5) To read value from file
CONFIG
.getProperty("mainsite");
Some more system properties can be read from system as well
ex: System.getproperty("user.dir") for project


Wil share a sample code some time later but the above steps should help.