Quaatso Education

Home Forums Selenium Forum Not able to open the url while using chrome driver

Not able to open the url while using chrome driver

This topic contains 5 replies, has 2 voices, and was last updated by  Shobhna Garg 11 months, 1 week ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #4050

    Shobhna Garg
    Participant

    Following error message appears “Starting ChromeDriver 2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129) on port 13631¬†Only local connections are allowed.”

    #4051

    Nandan Singh
    Keymaster

    Hi Shobhna, please paste your code here.

    #4052

    Shobhna Garg
    Participant

    package testCode;

     

    import java.io.File;

    import java.io.IOException;

    import java.util.concurrent.TimeUnit;

     

    import org.openqa.selenium.By;

    import org.openqa.selenium.WebDriver;

    import org.openqa.selenium.chrome.ChromeDriver;

    import org.testng.annotations.AfterClass;

    import org.testng.annotations.BeforeClass;

    import org.testng.annotations.BeforeMethod;

    import org.testng.annotations.DataProvider;

    import org.testng.annotations.Test;

     

    import testData.CsvTestData;

     

    public class LoginTest {

     

    WebDriver driver ;

     

    @BeforeClass

    public void init()

    {

    File f = new File(“D:\\chromedriver.exe”);

    System.setProperty(“webdriver.chrome.driver”,f.getAbsolutePath());

    driver = new ChromeDriver();

    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    driver.manage().window().maximize();

    }

     

    @BeforeMethod

    public void openUrl()

    {

    driver.get(“https://www.facebook.com/”);

     

     

    }

     

    @Test (dataProvider = “getCsvData”)

    public void verifyLogin(String userName, String password)

    {

    driver.findElement(By.id(“email”)).sendKeys(userName);

    driver.findElement(By.id(“pass”)).sendKeys(password);

    driver.findElement(By.id(“loginbutton”)).click();

    }

     

     

    @AfterClass

    public void tearDown()

    {

    driver.quit();

    }

    @DataProvider

    public Object[][] getCsvData() throws IOException

    {

    Object[][] data = CsvTestData.getCsvData();

    return data;

    }

    }

     

    #4082

    Shobhna Garg
    Participant

    package testData;

     

    import java.io.BufferedReader;

    import java.io.File;

    import java.io.FileReader;

    import java.io.IOException;

    import java.util.ArrayList;

     

     

    public class CsvTestData {

     

     

    public static void main(String[] args) throws IOException {

    getCsvData();

    }

     

    //@Paramters

    public static Object[][] getCsvData() throws IOException

     

    {

    ArrayList<String> dataList = new ArrayList<String>();

     

    File f = new File(“C:\\Users\\shobhna\\Desktop\\testdata.csv”);

    FileReader fr = new FileReader(f);

    BufferedReader reader = new BufferedReader(fr);

    String line = null;

    int row = 0;

    int Columns = 0;

    while ((line = reader.readLine())!= null)

    {

    if (row == 0)

    continue;

    if(line.charAt(0) == ‘#’)

    continue;

     

    String [] lineArray = line.split(“,”);

    Columns = lineArray.length;

    for (int i = 0; i < lineArray.length; i++)

    {

    String data = lineArray[i];

    dataList.add(data);

     

    } row ++;

     

    }

    reader.close();

     

    // converting from 1d to 2d

    Object [][] csvDataArray = new Object [row][Columns];

    int index = 0;

    for (int i=0 ; i < csvDataArray.length ; i++)

    {

    for (int j=0; j < csvDataArray[i].length; j++)

    {

    csvDataArray[i][j]= dataList.get(index);

    index ++;

    }

    }

    // just for testing this code

    for (int i = 0; i < csvDataArray.length; i++) {

    for (int j = 0; j < csvDataArray[i].length; j++) {

    System.out.print(csvDataArray[i][j] + “\t”);

    }

    System.out.println();

    }

     

     

    return csvDataArray;

    }

     

    }

     

    #4083

    Nandan Singh
    Keymaster

    Shobhna, your file is saved in desktop/”C” drive. In Windows there is a security feature which stops any program to access files directly. So Please save this file on any other directory / drive and try to access again.

    #4103

    Shobhna Garg
    Participant

    I have tried that. But still it doesn’t work.

     

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.