harika sanagani
harika sanagani

Reputation: 11

I'm unable to setup selenium grid for appium server with two devices on mac

I'm trying to run appium scripts on multiple devices in parallel. For that I tried setup appium server(appium v1.6.3) using selenium grid.

Approach I followed: 1. Created Hub.json file

  1. Created nodeconfig json files for two devices

  2. Placed all of them in one folder along with selenium-server-standalone-2.53.0.jar file

  3. In terminal, run the command:

    java -jar selenium-server-standalone-2.53.0.jar -role hub -hubConfig /Users/CH0006/Proj_Documentation/Testing/Appium/selenium_config/hub.json

  4. and then run nodeconfig,

    node appium --nodeconfig /Users/CH0006/Proj_Documentation/Testing/Appium/selenium_config/iPadmini.json -p 4723

I see below error here:

CH0006s-Mac-mini:lib CH0006$ node appium --nodeconfig /Users/CH0006/Proj_Documentation/Testing/Appium/selenium_config/iPadmini.json -p 4040
/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/appium.js:1
(function (exports, require, module, __filename, __dirname) { import _ from 'loads';

SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:78:16)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:420:7)
at startup (bootstrap_node.js:139:9)
at bootstrap_node.js:535:3 

Note: Appium.js doesn't exist in bin folder, so that I used path of lib folder where appium.js exists.

Configurations:

Hub.json:

{
"newSessionWaitTimeout" : -1,
"timeout" : 30000,
 "capabilityMatcher" : "org.openga.grid.internal.utils.DefaultCapabilityMatcher",
 "servlets" : [],
  "maxSession" : 5,
  "prioritizer" : null,
"host" : null,
"throwOnCapabilityNotPresent" : true,
  "nodePolling" : 5000,
"CleanUpCycle" : 5000,
"browserTimeout" : 90000,
 "port" : 4444
}

device1.json:

{
"configuration" : {
"registerCycle" : 5000,
"timeout" : 600000,
"maxSession" : 1,
"cleanCycle" : 5000,
"nodeTimeout" : 120,
"hubHost" : "localhost",
"host" : "localhost",
"nodePolling" : 2000,
 "hubPort" : 4444,
"role" : "node",
},
"capabilities" : [
{
"platformName" : "iOS",
 "version" : "10.1.1",
"maxInstances" : 4,
 "deviceName" : "iPad mini",
"browserName" : "iOS",
 "platform" : "MAC"
}
]
}

Upvotes: 0

Views: 525

Answers (1)

harika sanagani
harika sanagani

Reputation: 11

  1. Created Node.json file for each device, create one txt file for each device and place them in one folder
  2. Place selenium-server-standalone-2.53.0.jar in same folder
  3. Run java -jar selenium-server-standalone-2.53.0.jar -role hub in terminal going to that folder where jar is located
  4. In other terminal window - run debug proxy ios_webkit_debug_proxy -c 7f5bc36b71a4d44161c128464c9d516d2ec3af94:27755 -d
  5. In other terminal window - go to path where appium located - and run

    node appium --session-override --nodeconfig /Users/CH0006/Proj_Documentation/Testing/Appium/selenium_config/node3.json --show-ios-log --tmp /Users/CH0006/Proj_Documentation/Testing/Appium/selenium_config/device2 -p 4730 --bootstrap-port 4467 --udid 7f5bc36b71a4d44161c128464c9d516d2ec3af94 --webkit-debug-proxy-port 27755 --full-reset --native-instruments-lib --safari > /Users/CH0006/Proj_Documentation/Testing/Appium/selenium_config/iphone6s.txt

Note: If u r using appium v1.6 or above - better use ./node_modules/.bin/appium instead of node appium (It will find the appium path automatically)

6. Create one testng xml file in project and write code

    <?xml version="1.0" encoding="UTF-8"?> 
    <!DOCTYPE suite SYSTEM "http://www.testng.org/testng-1.0.dtd"> 
    <suite name="Default Suite" parallel="tests"> 
    <test verbose="2" name="Device1"> 
    <parameter name="Device_ID" value="6f307db6c72271c87b5936cf08aac61134001cc4" />
    <parameter name="wdaPort" value="8200" />
    <classes> 
    <class name="SampleAppTest.SampleAppScan"> 
    <methods> <include name="ID1Scan"/> </methods> 
    </class>
    </classes> 
    </test> 
  1. Create a class and write code to execute
  2. Go to xml and run the test with testNG

Upvotes: 1

Related Questions