Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » how to give a path on java on Mac
how to give a path on java on Mac [message #1074403] Fri, 26 July 2013 17:21 Go to next message
shiva r is currently offline shiva rFriend
Messages: 1
Registered: July 2013
Junior Member
We're learning file input and output in my programming class right now, but I have a Macbook Pro. I understand how to do it and I can do it on Windows but I'm having trouble finding out how to do it exactly for a Mac.


package selenium_pack;
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.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

public class Properties_File_Example {

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

WebDriver wd= new FirefoxDriver ();
wd.get("http:gmail.com");
Properties p = new Properties ();
FileInputStream f = newFileInputStream("//Users//mymac//Desktop//Selenimprojects//WD//src//selenium_pack//ObjectRepository.txt");
p.load(f);
wd.findElement (By.id(p.getProperty("un"))).sendKeys("username");
wd.findElement (By.id(p.getProperty("pw"))).sendKeys("password");
wd.findElement (By.id(p.getProperty("lin"))).click ();




}

}


Data in the file named ObjectRepository

un=Email
pw=Passwd
lin=signIn



( This works perfectly fine when i run this program in windows xp)

Error Message

Exception in thread "main" java.io.FileNotFoundException: /Users/mymac/Desktop/Selenimprojects/WD/src/selenium_pack/ObjectRepository.txt (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:120)
at java.io.FileInputStream.<init>(FileInputStream.java:79)
at selenium_pack.Properties_File_Example.main(Properties_File_Example.java:19)
Re: how to give a path on java on Mac [message #1075240 is a reply to message #1074403] Mon, 29 July 2013 05:15 Go to previous message
Aaron Skelsey is currently offline Aaron SkelseyFriend
Messages: 4
Registered: July 2013
Junior Member
I'm not a Mac user, but I understand it is essentially UNIXy
If you go to a terminal window and type:
"cat /Users/mymac/Desktop/Selenimprojects/WD/src/selenium_pack/ObjectRepository.txt"
does it show the contents of your file?
Previous Topic:How to create .apk by importing gideros android project
Next Topic:app to computer?
Goto Forum:
  


Current Time: Mon Dec 22 21:23:59 GMT 2014

Powered by FUDForum. Page generated in 0.01891 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software