Facing error after executing Script written in java(Selenium WEbdriver)

0

I have created the two files.
First file in which I have given the browser name and Url.
Second file in which I have given the logical names to the xpath.

I have created the two class correspondingly.
In first class, I have created all the functions.
In second class, iam calling that functions (using inheritance concept[extends]) which are there in the first class.

Uploading all the files.
First File:

Browser=Firefox
AppURL=https://www.myntra.com/

Second File:

Myntra_Search_Xpath=.//*[@id='desktop-header-cnt']/div/div[3]/input

First class

package Basepack;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;

public class baseclass {
    public static FirefoxDriver driver;

    public static String  getpropValue(String PName) throws IOException{
        Properties prop=new Properties();
        FileInputStream pi=new FileInputStream("C:\\Users\\Desktop\\workspace\\SeleFirstClass\\src\\Basepack\\Objprop");
        prop.load(pi);
        String Pvalue=prop.getProperty(PName);
        return Pvalue;

    }

    public static String getpathValue(String Pname) throws IOException{
        Properties prop=new Properties();
        FileInputStream pi=new FileInputStream("C:\\Users\\Desktop\\workspace\\SeleFirstClass\\src\\Basepack\\Objpath");
        prop.load(pi);
        String Pvalue=prop.getProperty(Pname);
        return Pvalue;

    }
    public static void openBrowser(){
        System.setProperty("webdriver.gecko.driver", "D:\\Selenium\\geckodriver.exe");
        driver=new FirefoxDriver();

    }
    public static void navigate(String URLName) throws IOException{
     String path=getpropValue(URLName);
     driver.get(path);
    }
    public static void closeBrowser(){
        driver.close();
    }
    public static void click(String Value) throws IOException{
        String path=getpathValue(Value);
        driver.findElement(By.xpath(path)).click();
    }

    public static void type(String path, String Value) throws IOException{
        String Locator=getpathValue(path);
        driver.findElement(By.xpath(Locator)).sendKeys(Value);
    }

public static void wait(int i) throws InterruptedException
   {
      Thread.sleep(i*1000);
   }
}

Second Class

package Basepack;

import java.io.IOException;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class FirstTestNG extends baseclass{
    @BeforeMethod
    public void beforemethod() throws IOException, InterruptedException
    {
        openBrowser();
        navigate("AppURL");
        wait(3000);

    }
    @AfterMethod
    public void aftermethod()
    {
        closeBrowser();
    }

    @Test
    public void invalidlogin1() throws IOException, InterruptedException
    {
        wait(3000);
        type("Flipkart_login_Xpath", "Nike Shoes");
    }

}

Following is the error description

1494929368178   geckodriver INFO    Listening on 127.0.0.1:8576
1494929368783   geckodriver::marionette INFO    Starting browser \\?\C:\Program Files\Mozilla Firefox\firefox.exe with args ["-marionette"]
1494929369821   addons.manager  ERROR   startup failed: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIFile.create]"  nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)"  location: "JS frame :: resource://gre/modules/FileUtils.jsm :: FileUtils_getDir :: line 70"  data: no] Stack trace: FileUtils_getDir()@resource://gre/modules/FileUtils.jsm:70 < FileUtils_getFile()@resource://gre/modules/FileUtils.jsm:42 < AddonManagerInternal.validateBlocklist()@resource://gre/modules/AddonManager.jsJavaScmr:i6p6t5  e<r rAodrd:o nrMeasnoaugrecreI:n/t/egrrnea/lm.osdtualretsu/pA(d)d@orneMsaonuargceer:./j/sgmr,e /lmionde 1639: NS_ERROR_NOT_INITIALIZED: AddonManager is not initialized
ules/AddonManager.jsm:832 < this.AddonManagerPrivate.startup()@resource://gre/modules/AddonManager.jsm:2773 < amManager.prototype.observe()@resource://gre/components/addonManager.js:57
1494929371707   Marionette  INFO    Listening on port 53003
JavaScript error: undefined, line 492: Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIPrefBranch.getCharPref]
JavaScript error: resource://gre/modules/AddonManager.jsm, line 2484: NS_ERROR_NOT_INITIALIZED: AddonManager is not initialized
May 16, 2017 3:39:33 PM org.openqa.selenium.remote.ProtocolHandshake createSession`enter code here`INFO: Detected dialect: W3C
java
selenium-webdriver
asked on Stack Overflow May 16, 2017 by VaneetK • edited May 21, 2017 by juherr

1 Answer

0

try adding DesiredCapabilities

   DesiredCapabilities capabilities = DesiredCapabilities.firefox();
   capabilities.setCapability("marionette", true);
   WebDriver driver = new FirefoxDriver(capabilities);  
answered on Stack Overflow May 16, 2017 by Mohamed Rafiudeen

User contributions licensed under CC BY-SA 3.0