0
0
Selenium Javatesting~10 mins

Page title and URL retrieval 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 get the page title using Selenium WebDriver.

Selenium Java
String title = driver.[1]();
Drag options to blanks, or click blank then click option'
AgetTitle
BgetUrl
CgetCurrentUrl
DgetPageSource
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
2fill in blank
medium

Complete 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'
AgetTitle
BgetCurrentUrl
CgetUrl
DgetPageSource
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
3fill in blank
hard

Fix 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'
AgetCurrentUrl()
BgetTitle
CgetTitle()
DgetPageSource()
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting parentheses after method name
Using getCurrentUrl() when title is needed
4fill in blank
hard

Fill 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'
AgetTitle
BgetPageSource
CgetCurrentUrl
DgetUrl
Attempts:
3 left
💡 Hint
Common Mistakes
Using getPageSource() instead of getTitle()
Using getUrl() which is not a valid method
5fill in blank
hard

Fill 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'
AgetTitle
BgetCurrentUrl
Ccontains
DstartsWith
Attempts:
3 left
💡 Hint
Common Mistakes
Using getUrl() which is invalid
Using startsWith() instead of contains() for substring check
Omitting parentheses on method calls