Browser interactions
Get browser information
Coletar título
Você pode ler o título da página atual no navegador:
      String title = driver.getTitle();/examples/java/src/test/java/dev/selenium/interactions/InteractionsTest.java
package dev.selenium.interactions;
import dev.selenium.BaseChromeTest;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.Cookie;
import java.util.Set;
public class InteractionsTest extends BaseChromeTest {
  @Test
  public void getTitle() {
    try {
      driver.get("https://www.selenium.dev/");
      // get title
      String title = driver.getTitle();
      Assertions.assertEquals(title, "Selenium");
    } finally {
      driver.quit();
    }
  }
  @Test
  public void getCurrentUrl() {
    try {
      driver.get("https://www.selenium.dev/");
      // get current url
      String url = driver.getCurrentUrl();
      Assertions.assertEquals(url, "https://www.selenium.dev/");
    } finally {
      driver.quit();
    }
  }
}title = driver.title/examples/python/tests/interactions/test_interactions.py
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.selenium.dev")
title = driver.title
assert title == "Selenium"
url = driver.current_url
assert url == "https://www.selenium.dev/"
driver.quit()
            String title = driver.Title;/examples/dotnet/SeleniumDocs/Interactions/InteractionsTest.cs
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace SeleniumDocumentation.SeleniumInteractions
{
    [TestClass]
    public class InteractionsTest
    {
        [TestMethod]
        public void TestInteractions()
        {
            WebDriver driver = new ChromeDriver();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);
            // Navigate to Url
            driver.Url="https://www.selenium.dev/";
            //GetTitle
            String title = driver.Title;
            Assert.AreEqual(title, "Selenium");
            //GetCurrentURL
            String url = driver.Url;
            Assert.AreEqual(url, "https://www.selenium.dev/");
            //quitting driver
            driver.Quit(); //close all windows
        }
    }
}  it 'gets the current title' do/examples/ruby/spec/interactions/browser_spec.rb
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Browser' do
  let(:driver) { start_session }
  it 'gets the current title' do
    driver.navigate.to 'https://www.selenium.dev/'
    current_title = driver.title
    expect(current_title).to eq 'Selenium'
  end
  it 'gets the current url' do
    driver.navigate.to 'https://www.selenium.dev/'
    current_url = driver.current_url
    expect(current_url).to eq 'https://www.selenium.dev/'
  end
end
    let title = await driver.getTitle();/examples/javascript/test/interactions/interactionsIndex.spec.js
const {Builder } = require('selenium-webdriver');
const assert = require("node:assert");
describe('Interactions', function () {
  let driver;
  before(async function () {
    driver = new Builder()
      .forBrowser('chrome')
      .build();
  });
  after(async () => await driver.quit());
  it('Should be able to get title and current url', async function () {
    const url = 'https://www.selenium.dev/';
    await driver.get(url);
    //Get Current title
    let title = await driver.getTitle();
    assert.equal(title, "Selenium");
    //Get Current url
    let currentUrl = await driver.getCurrentUrl();
    assert.equal(currentUrl, url);
  });
});driver.titleColetar a URL atual
Você pode ler a URL atual na barra de endereço do navegador usando:
      String url = driver.getCurrentUrl();/examples/java/src/test/java/dev/selenium/interactions/InteractionsTest.java
package dev.selenium.interactions;
import dev.selenium.BaseChromeTest;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.Cookie;
import java.util.Set;
public class InteractionsTest extends BaseChromeTest {
  @Test
  public void getTitle() {
    try {
      driver.get("https://www.selenium.dev/");
      // get title
      String title = driver.getTitle();
      Assertions.assertEquals(title, "Selenium");
    } finally {
      driver.quit();
    }
  }
  @Test
  public void getCurrentUrl() {
    try {
      driver.get("https://www.selenium.dev/");
      // get current url
      String url = driver.getCurrentUrl();
      Assertions.assertEquals(url, "https://www.selenium.dev/");
    } finally {
      driver.quit();
    }
  }
}url = driver.current_url/examples/python/tests/interactions/test_interactions.py
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.selenium.dev")
title = driver.title
assert title == "Selenium"
url = driver.current_url
assert url == "https://www.selenium.dev/"
driver.quit()
            String url = driver.Url;/examples/dotnet/SeleniumDocs/Interactions/InteractionsTest.cs
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace SeleniumDocumentation.SeleniumInteractions
{
    [TestClass]
    public class InteractionsTest
    {
        [TestMethod]
        public void TestInteractions()
        {
            WebDriver driver = new ChromeDriver();
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500);
            // Navigate to Url
            driver.Url="https://www.selenium.dev/";
            //GetTitle
            String title = driver.Title;
            Assert.AreEqual(title, "Selenium");
            //GetCurrentURL
            String url = driver.Url;
            Assert.AreEqual(url, "https://www.selenium.dev/");
            //quitting driver
            driver.Quit(); //close all windows
        }
    }
}  it 'gets the current url' do/examples/ruby/spec/interactions/browser_spec.rb
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Browser' do
  let(:driver) { start_session }
  it 'gets the current title' do
    driver.navigate.to 'https://www.selenium.dev/'
    current_title = driver.title
    expect(current_title).to eq 'Selenium'
  end
  it 'gets the current url' do
    driver.navigate.to 'https://www.selenium.dev/'
    current_url = driver.current_url
    expect(current_url).to eq 'https://www.selenium.dev/'
  end
end
    let currentUrl = await driver.getCurrentUrl();/examples/javascript/test/interactions/interactionsIndex.spec.js
const {Builder } = require('selenium-webdriver');
const assert = require("node:assert");
describe('Interactions', function () {
  let driver;
  before(async function () {
    driver = new Builder()
      .forBrowser('chrome')
      .build();
  });
  after(async () => await driver.quit());
  it('Should be able to get title and current url', async function () {
    const url = 'https://www.selenium.dev/';
    await driver.get(url);
    //Get Current title
    let title = await driver.getTitle();
    assert.equal(title, "Selenium");
    //Get Current url
    let currentUrl = await driver.getCurrentUrl();
    assert.equal(currentUrl, url);
  });
});driver.currentUrlVirtual Authenticator
Uma representação do modelo Web Authenticator.
Última modificação July 29, 2025: Adding trailing / to retrieve code from GitHub (48b97e9bf8)




