Sunday, 22 January 2017

MongoDB Session 2 : Miscellaneous things during start MongoDB server

Keep below points in mind before starting MongoDB

1. Create folder "data" inside that another folder "db" in the same drive where you installed MongoDB
2. Installing drive should contain free space more than 3GB
Reason: MongoDB stores all DB details in c:\data\db  ( Check path where you created folder "data\db")
Note: try to create data\db folder on the same drive where you installed MongoDB software.

What if space is not available ...? hmm you will get below error while starting MongoDB server



3.You have to open two cmd prompt one for starting MongoDB server and second for opening MongoDB shell prompt.
Note: Don't close the first cmd window. If you close then the server will stop.
4.If you facing problem in starting server then check in case data/db folder contains MongoDB.lock file. if so it means MongoDB server is already running and you can't run that again.

Error message looks like 

Saturday, 21 January 2017

MongoDB Session 1 : Installing MongoDB For Windows 7

1. Download mongodb for win7 from MongoDB official website
    https://www.mongodb.com/


2. Install downloaded .exe file by double clicking. 
         This is as simple as any .exe installation . Just remember in which drive you are installing
3. Check installed directory




4.Create  "data/db" empty folder in same drive where you installed Mongo. In my case its C:
         i.e "C:/data/db".
         
  • Reason: MongoDB stores temp,DB related files in this folder. It will throgh error message if it dint find these folders.
  • Temp/DB Files? :  Yes! it stores some mongoDB related files. For ex : if I create "Student DB" and in that I create some collections. Then two files will be generated in                   "C:/data/db" . i.e student.0 and student.ns.
  • Comparing RDBMS terminology with NoSQL DB/Unstructured DB (MongoDB).
         Data Base                 : Data Base. 
         Tables                      : Collections.
         Rows & Columns     : Documents/Records.
 
5. Run MongoDB server 
         You have to start MongoDB server before performing any DB operation. This is same as any              other relational DB . That is if you are using Oracle DB , then Oracle DB must be running                  then you can connect to it by using terminal (SQL+) or any sql editior (SQL Developer).
  • Open new command prompt : Type "cmd" in Run prompt.
  • change path to installed directory . i.e "cd C:\Program Files\MongoDB 2.6 Standard\bin".
  • type "mongodb" and press enter
        
        Once you see the control stops displaying any logger and without any error message it means MongoDB is started.
Note : Dont close this window. If you close then server will stops running.

6. Opening MongoDB prompt/Shell to perform DB operation
  • Open new command prompt : Type "cmd" in Run prompt.
  • change path to installed directory . i.e "cd C:\Program Files\MongoDB 2.6 Standard\bin".
  • type "mongo" and press enter

Thats All..! You are done with instalation and opening Mongo Shell.


Starting Appium through Automation

Prerequisites : Hope you already know selenium and TestNg and your eclipse is set for these.
We need few extra jars to achive this appium starting through java code. so download below jars and add it to build path.

1. gson-2.8.0.jar
2. java-client-3.2.0.jar
3. commons-validator-1.4.0.jar


Code:

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeClass;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServiceBuilder;

public class AppiumStartStop
{

AppiumDriverLocalService service;

@BeforeClass
public void init()
{
System.out.println("Starting Appium ... !");

service = AppiumDriverLocalService
.buildService(new AppiumServiceBuilder()
.usingDriverExecutable(new File("C:/Program Files/nodejs/node.exe"))
.withAppiumJS(new File("C:/Program Files (x86)/Appium/node_modules/appium/bin/appium.js"))
.withLogFile(new File("d:/logs.txt")));

service.start();
}

@Test
public void appiumTesting() throws MalformedURLException
{

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("automationName","Appium");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "6.0.1");
capabilities.setCapability("deviceName","Manjus");
capabilities.setCapability("appPackage", "io.selendroid.testapp");
capabilities.setCapability("appActivity", "HomeScreenActivity");
AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.get("https://shirageri.blogspot.in");
}

        @AfterClass
public void tearDown()
{
System.out.println("Stopping Appium ... !");
service.stop();
}

}