Skip to content

Navigation

Using the methods below you will be able to manipulate the navigation in the browser and also manage different pages and tabs.

Start Browser

You can start the selected browser. This method does not open the browser, it just sets the default settings and leaves it ready to use.

# Start the selected browser.
bot.start_browser()
// Start the selected browser.
startBrowser();

Stop Browser

Invoking the stop browser will finish and release the web driver.

Important

This method MUST always be invoked at the end of the automation as to ensure proper release of resources used by the Web Driver.

Failure to do so can cause memory leaks.

# Stop the browser and clean up.
bot.stop_browser()
// Stop the browser and clean up.
stopBrowser();

Browse

You can access a URL using the selected browser.

# Opens the browser on the BotCity website.
bot.browse("https://botcity.dev")

# Using navigate_to will have the same effect.
bot.navigate_to("https://botcity.dev")
// Opens the browser on the BotCity website.
browse("https://botcity.dev");

// Using navigateTo will have the same effect.
navigateTo("https://botcity.dev");

In addition to opening the browser in a specific URL, it is also possible to browse new pages and interact with previously accessed pages during the process.

Back

# Accessing a first page.
bot.browse("https://botcity.dev")

# Navigating to a second page.
bot.navigate_to("https://blog.botcity.dev")

# Goes one step backward in the browser history (in this case, back to the first page).
bot.back()
// Accessing a first page.
browse("https://botcity.dev");

// Navigating to a second page.
navigateTo("https://blog.botcity.dev");

// Goes one step backward in the browser history (in this case, back to the first page).
back();

Forward

# Goes one step forward in the browser history.
bot.forward()
// Goes one step forward in the browser history.
forward();

Refresh

# Refreshing the current page.
bot.refresh()
// Refreshing the current page.
refresh();

Get Tabs

You can get a list of handlers for the tabs that are open.

# Getting the tab handlers.
opened_tabs = bot.get_tabs()
print(opened_tabs)
// Getting the tab handlers.
List<String> openedTabs = getTabs();

for(String tabHandler : openedTabs) {
    System.out.println(tabHandler);
}

Activate Tab

With a tab handler you can activate the tab and thus access the context of that page. This can be useful when you start with operations on a page and then need to continue the process on a new page that has been opened.

# Getting the list of tab handlers.
opened_tabs = bot.get_tabs()

# Getting the handle of a new open tab.
new_tab = opened_tabs[1]

# Activating the tab as the current context.
bot.activate_tab(new_tab)
// Getting the list of tab handlers.
List<String> openedTabs = getTabs();

// Getting the handle of a new open tab.
String newTab = openedTabs.get(1);

// Activating the tab as the current context.
activateTab(newTab);

Create Tab

You can create a new tab and navigate to the given URL.

# Starting the browser.
bot.browse("https://google.com")

# Opening a new tab in the browser.
bot.create_tab("https://botcity.dev")
// Starting the browser.
browse("https://google.com");

// Opening a new tab in the browser.
createTab("https://botcity.dev");

Create Window

In addition to creating a new tab in the same window, it is also possible to create a new window with the given URL.

# Starting the browser.
bot.browse("https://google.com")

# Opening a new window.
bot.create_window("https://botcity.dev")
// Starting the browser.
browse("https://google.com");

// Opening a new window.
createWindow("https://botcity.dev");

Close Page

You can easily close the current active page (tab or window).

# Closing the current context.
bot.close_page()
// Closing the current context.
closePage();