0
0
Selenium Javatesting~10 mins

Properties file for configuration in Selenium Java - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load a properties file in Java.

Selenium Java
Properties prop = new Properties();
FileInputStream fis = new FileInputStream("config.properties");
prop.[1](fis);
Drag options to blanks, or click blank then click option'
Aopen
Bload
Cread
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'read' instead of 'load' causes a compile error.
2fill in blank
medium

Complete the code to get the value of a property named 'url'.

Selenium Java
String url = prop.[1]("url");
Drag options to blanks, or click blank then click option'
AgetProperty
Bget
Cfetch
DreadProperty
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' causes a compile error because Properties does not have a 'get' method.
3fill in blank
hard

Fix the error in the code to properly close the FileInputStream.

Selenium Java
FileInputStream fis = new FileInputStream("config.properties");
try {
    prop.load(fis);
} finally {
    fis.[1]();
}
Drag options to blanks, or click blank then click option'
Aclose
Bshutdown
Cdispose
Dend
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'shutdown' or 'dispose' causes compile errors because these methods don't exist for FileInputStream.
4fill in blank
hard

Fill both blanks to create a Properties object and load the file safely using try-with-resources.

Selenium Java
try (FileInputStream fis = new FileInputStream("config.properties")) {
    Properties [1] = new Properties();
    [2].load(fis);
}
Drag options to blanks, or click blank then click option'
Aprop
BfileStream
Cconfig
Dproperties
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names causes confusion and errors.
5fill in blank
hard

Fill all three blanks to read a property 'browser' and print it.

Selenium Java
Properties prop = new Properties();
try (FileInputStream [1] = new FileInputStream("config.properties")) {
    prop.load([1]);
    String browser = prop.[2]("browser");
    System.out.println("Browser: " + [3]);
}
Drag options to blanks, or click blank then click option'
Afis
BgetProperty
Cbrowser
DfileInput
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names or method names causes errors or wrong output.