Programe o seu primeiro script Selenium
Assim que você tiver o Selenium instalado, você estará pronto para programar códigos Selenium.
Oito Componentes Básicos
Tudo que o Selenium faz é enviar comandos ao navegador de internet para fazer algo ou solicitar informações dele. A maior parte do que você irá fazer com o Selenium é uma combinação desses comandos básicos.
Click on the link to “View full example on GitHub” to see the code in context.
1. Iniciando uma sessão
Para ter mais detalhes sobre como iniciar uma sessão, leia nossa documentação em driver sessions
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
2. Agindo no navegador de internet
Nesse exemplo estamos navegando para uma página web.
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
3. Solicitando informação do navegador de internet
Existem diversos tipos de informação sobre o navegador de internet que você pode solicitar, incluindo window handles, tamanho / posição do navegador, cookies, alertas e etc.
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
4. Estabelecendo uma Estratégia de Espera
Sincronizar o código ao estado atual do navegador é um dos maiores desafios quando se trabalha com o Selenium, fazer isso de maneira bem feita é um tópico avançado.
Essencialmente, você quer ter certeza absoluta de que o elemento está na página antes de tentar localizá-lo e o elemento está em um estado interativo antes de você tentar interagir com ele.
Uma espera implícita raramente é a melhor solução, mas é a mais fácil de demonstrar aqui, então vamos usá-la como um substituto.
Leia mais sobre Estratégias de espera.
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
5. Encontrando um elemento
A maioria dos comandos na maior parte das sessões do Selenium são relacionados a elementos e você não pode interagir com um sem o primeiro encontrando um elemento
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
6. Agindo no elemento
Há apenas um punhado de ações a serem executadas em um elemento, mas você irá usá-las com frequência.
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
7. Solicitando informações do elemento
Elementos podem guardar muitas informações que podem ser solicitadas.
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
8. Encerrando a sessão
Isso encerra o processo do driver, que por padrão também fecha o navegador. Nenhum outro comando pode ser enviado para esta instância do driver.
See Quitting Sessions.
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
Running Selenium File
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
SELENIUM_CI_TOKEN not set
If you want to render content fetched from the GitHub API, please create a
personal access token
and set it as an environment variable named SELENIUM_CI_TOKEN. More information about token scopes can
be seen at
available scopes GitHub docs
Próximos Passos
Most Selenium users execute many sessions and need to organize them to minimize duplication and keep the code more maintainable. Read on to learn about how to put this code into context for your use case with Using Selenium.




