Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to get the page title using Selenium WebDriver.
Selenium Java
String title = driver.[1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using getCurrentUrl() instead of getTitle()
Using getUrl() which is not a valid method
Using getPageSource() which returns HTML source, not title
✗ Incorrect
The getTitle() method returns the title of the current page.
2fill in blank
mediumComplete the code to get the current page URL using Selenium WebDriver.
Selenium Java
String url = driver.[1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using getTitle() instead of getCurrentUrl()
Using getUrl() which is not a valid method
Using getPageSource() which returns HTML source, not URL
✗ Incorrect
The getCurrentUrl() method returns the URL of the current page.
3fill in blank
hardFix the error in the code to correctly print the page title.
Selenium Java
System.out.println(driver.[1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting parentheses after method name
Using getCurrentUrl() when title is needed
✗ Incorrect
The method getTitle() must be called with parentheses to execute and return the title.
4fill in blank
hardFill both blanks to store the page title and URL in variables.
Selenium Java
String pageTitle = driver.[1](); String pageUrl = driver.[2]();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using getPageSource() instead of getTitle()
Using getUrl() which is not a valid method
✗ Incorrect
getTitle() gets the page title, and getCurrentUrl() gets the current URL.
5fill in blank
hardFill all three blanks to print the page title, URL, and check if URL contains 'example'.
Selenium Java
String title = driver.[1](); String url = driver.[2](); boolean containsExample = url.[3]("example");
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using getUrl() which is invalid
Using startsWith() instead of contains() for substring check
Omitting parentheses on method calls
✗ Incorrect
Use getTitle() for title, getCurrentUrl() for URL, and contains() to check substring.