|
| 1 | +--- |
| 2 | +title: "El Proyecto para Automatización de Navegadores Selenium" |
| 3 | +--- |
| 4 | + |
| 5 | +{{% notice info %}} |
| 6 | +<i class="fas fa-language"></i> Page being translated from |
| 7 | +English to Spanish. Do you speak Spanish? Help us to translate |
| 8 | +it by sending us pull requests! |
| 9 | +{{% /notice %}} |
| 10 | + |
| 11 | +# El Proyecto para Automatización de Navegadores Selenium |
| 12 | + |
| 13 | +Selenium is an umbrella project for a range of tools and libraries |
| 14 | +that enable and support the automation of web browsers. |
| 15 | + |
| 16 | +It provides extensions to emulate user interaction with browsers, |
| 17 | +a distribution server for scaling browser allocation, |
| 18 | +and the infrastructure for implementations of the |
| 19 | +[W3C WebDriver specification](//www.w3.org/TR/webdriver/) |
| 20 | +that lets you write interchangeable code for all major web browsers. |
| 21 | + |
| 22 | +This project is made possible by volunteer contributors |
| 23 | +who have put in thousands of hours of their own time, |
| 24 | +and made the source code [freely available](attr.md#license) |
| 25 | +for anyone to use, enjoy, and improve. |
| 26 | + |
| 27 | +Selenium brings together browser vendors, engineers, and enthusiasts |
| 28 | +to further an open discussion around automation of the web platform. |
| 29 | +The project organises [an annual conference](//seleniumconf.com/) |
| 30 | +to teach and nurture the community. |
| 31 | + |
| 32 | +At the core of Selenium is _[WebDriver]({{< ref "/webdriver/_index.md" >}})_, |
| 33 | +an interface to write instruction sets that can be run interchangeably in many |
| 34 | +browsers. Here is one of the simplest instructions you can make: |
| 35 | + |
| 36 | +{{< code-tab >}} |
| 37 | + {{< code-panel language="java" >}} |
| 38 | +import org.openqa.selenium.By; |
| 39 | +import org.openqa.selenium.Keys; |
| 40 | +import org.openqa.selenium.WebDriver; |
| 41 | +import org.openqa.selenium.WebElement; |
| 42 | +import org.openqa.selenium.firefox.FirefoxDriver; |
| 43 | +import org.openqa.selenium.support.ui.WebDriverWait; |
| 44 | + |
| 45 | +import static org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated; |
| 46 | + |
| 47 | +public class HelloSelenium { |
| 48 | + |
| 49 | + public static void main(String[] args) { |
| 50 | + WebDriver driver = new FirefoxDriver(); |
| 51 | + WebDriverWait wait = new WebDriverWait(driver, 10); |
| 52 | + try { |
| 53 | + driver.get("https://google.com/ncr"); |
| 54 | + driver.findElement(By.name("q")).sendKeys("cheese" + Keys.ENTER); |
| 55 | + WebElement firstResult = wait.until(presenceOfElementLocated(By.cssSelector("h3>a"))); |
| 56 | + System.out.println(firstResult.getText()); |
| 57 | + } finally { |
| 58 | + driver.quit(); |
| 59 | + } |
| 60 | + } |
| 61 | +} |
| 62 | + {{< / code-panel >}} |
| 63 | + {{< code-panel language="python" >}} |
| 64 | +from selenium import webdriver |
| 65 | +from selenium.webdriver.common.by import By |
| 66 | +from selenium.webdriver.common.keys import Keys |
| 67 | +from selenium.webdriver.support.ui import WebDriverWait |
| 68 | +from selenium.webdriver.support.expected_conditions import presence_of_element_located |
| 69 | + |
| 70 | +#This example requires Selenium WebDriver 3.13 or newer |
| 71 | +with webdriver.Firefox() as driver: |
| 72 | + wait = WebDriverWait(driver, 10) |
| 73 | + driver.get("https://google.com/ncr") |
| 74 | + driver.find_element_by_name("q").send_keys("cheese" + Keys.RETURN) |
| 75 | + first_result = wait.until(presence_of_element_located((By.CSS_SELECTOR, "h3>a"))) |
| 76 | + print(first_result.text) |
| 77 | + {{< / code-panel >}} |
| 78 | + {{< code-panel language="csharp" >}} |
| 79 | +using System; |
| 80 | +using OpenQA.Selenium; |
| 81 | +using OpenQA.Selenium.Firefox; |
| 82 | +using OpenQA.Selenium.Support.UI; |
| 83 | +using SeleniumExtras.WaitHelpers; |
| 84 | + |
| 85 | +class HelloSelenium |
| 86 | +{ |
| 87 | + static void Main() |
| 88 | + { |
| 89 | + using (IWebDriver driver = new FirefoxDriver()) |
| 90 | + { |
| 91 | + WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); |
| 92 | + driver.Navigate().GoToUrl("https://www.google.com/ncr"); |
| 93 | + driver.FindElement(By.Name("q")).SendKeys("cheese" + Keys.Enter); |
| 94 | + IWebElement firstResult = wait.Until(ExpectedConditions.ElementExists(By.CssSelector("h3>a"))); |
| 95 | + Console.WriteLine(firstResult.Text); |
| 96 | + } |
| 97 | + } |
| 98 | +} |
| 99 | + {{< / code-panel >}} |
| 100 | + {{< code-panel language="ruby" >}} |
| 101 | +require 'selenium-webdriver' |
| 102 | + |
| 103 | +driver = Selenium::WebDriver.for :firefox |
| 104 | +wait = Selenium::WebDriver::Wait.new(timeout: 10) |
| 105 | + |
| 106 | +begin |
| 107 | + driver.get 'https://google.com/ncr' |
| 108 | + driver.find_element(name: 'q').send_keys 'cheese', :return |
| 109 | + first_result = wait.until { driver.find_element(css: 'h3>a') } |
| 110 | + puts first_result.text |
| 111 | +ensure |
| 112 | + driver.quit |
| 113 | +end |
| 114 | + {{< / code-panel >}} |
| 115 | + {{< code-panel language="javascript" >}} |
| 116 | +const {Builder, By, Key, until} = require('selenium-webdriver'); |
| 117 | + |
| 118 | +(async function example() { |
| 119 | + let driver = await new Builder().forBrowser('firefox').build(); |
| 120 | + try { |
| 121 | + await driver.get('https://www.google.com/ncr'); |
| 122 | + await driver.findElement(By.name('q')).sendKeys('cheese', Key.RETURN); |
| 123 | + let firstResult = await driver.wait(until.elementLocated(By.css('h3>a')),10000); |
| 124 | + console.log(await firstResult.getText()); |
| 125 | + } finally { |
| 126 | + await driver.quit(); |
| 127 | + } |
| 128 | +})(); |
| 129 | + {{< / code-panel >}} |
| 130 | +{{< / code-tab >}} |
| 131 | + |
| 132 | + |
| 133 | +See the _[Quick Tour]({{< ref "/getting_started/quick.es.md" >}})_ for a full explanation |
| 134 | +of what goes on behind the scenes when you run this code. |
| 135 | +You should continue on to the [narrative documentation]({{< ref "/introduction/_index.md" >}}) |
| 136 | +to understand how you can [install]({{< ref "/selenium_installation/_index.md" >}}) and |
| 137 | +successfully use Selenium as a test automation tool, |
| 138 | +and scaling simple tests like this to run |
| 139 | +in large, distributed environments on multiple browsers, |
| 140 | +on several different operating systems. |
| 141 | + |
| 142 | +## Getting started |
| 143 | + |
| 144 | +If you are new to Selenium, |
| 145 | +we have a few resources that can help you |
| 146 | +get up to speed right away. |
| 147 | + |
| 148 | +* [Quick tour]({{< ref "/getting_started/quick.es.md" >}}) |
| 149 | + * [WebDriver]({{< ref "/getting_started/quick.es.md#webdriver" >}}) |
| 150 | + * [Remote Control]({{< ref "/getting_started/quick.es.md#remote-control" >}}) |
| 151 | + * [IDE]({{< ref "/getting_started/quick.es.md#ide" >}}) |
| 152 | + * [Grid]({{< ref "/getting_started/quick.es.md#grid" >}}) |
| 153 | + * [HTML Runner]({{< ref "/getting_started/quick.es.md#html-runner" >}}) |
| 154 | + |
0 commit comments