Robotium - Write to file in eclipse workspace or computer file system

Posted by Flavio Capaccio on Stack Overflow See other posts from Stack Overflow or by Flavio Capaccio
Published on 2013-10-03T10:35:49Z Indexed on 2013/10/17 15:56 UTC
Read the original article Hit count: 535

Filed under:
|
|

I'm running some tests using Robotium on an Android application that interacts with a web-portal.

I'd like to save some information to file; for example I need to save the id of the username I created from the app and I want to make it read from Selenium to run tests on web-portal to verify a webpage for that user has been created.

Is it possible?

Could someone suggest me a solution or a work-around?

This is an example of code, but it doesn't work (I want to write to a file for example on c:\myworkspace\filename.txt a string):

public void test_write_file(){
        if(!solo.searchText("HOME")){
            signIn("39777555333", VALID_PASSWORD);
        }

        try {
            String content = "This is the content to write into file";

            File file = new File("filename.txt");

            // if file doesnt exists, then create it
            if (!file.exists()) {
                file.createNewFile();
            }

            FileWriter fw = new FileWriter(file.getAbsoluteFile());
            BufferedWriter bw = new BufferedWriter(fw);
            bw.write(content);
            bw.close();

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        assertTrue(solo.searchText("HOME"));
    }

© Stack Overflow or respective owner

Related posts about android

Related posts about selenium