-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create new Getting Started page for Running Tests (#1479)
* first script should not use a test runner and can be executed standalone * move hello selenium out of SeleniumDocs * rename page and add section on Usage * add examples and links [deploy site]
- Loading branch information
1 parent
c5e63e2
commit b271cbd
Showing
35 changed files
with
1,394 additions
and
700 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using OpenQA.Selenium.Chrome; | ||
|
||
namespace SeleniumDocs.Hello; | ||
|
||
public static class HelloSelenium | ||
{ | ||
public static void Main() | ||
{ | ||
var driver = new ChromeDriver(); | ||
|
||
driver.Navigate().GoToUrl("https://selenium.dev"); | ||
|
||
driver.Quit(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
examples/dotnet/SeleniumDocs/GettingStarted/FirstScript.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Chrome; | ||
|
||
namespace SeleniumDocs.GettingStarted; | ||
|
||
public static class FirstScript | ||
{ | ||
public static void Main() | ||
{ | ||
IWebDriver driver = new ChromeDriver(); | ||
|
||
driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/web-form.html"); | ||
|
||
var title = driver.Title; | ||
|
||
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500); | ||
|
||
var textBox = driver.FindElement(By.Name("my-text")); | ||
var submitButton = driver.FindElement(By.TagName("button")); | ||
|
||
textBox.SendKeys("Selenium"); | ||
submitButton.Click(); | ||
|
||
var message = driver.FindElement(By.Id("message")); | ||
var value = message.Text; | ||
|
||
driver.Quit(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
examples/java/src/test/java/dev/selenium/getting_started/FirstScript.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package dev.selenium.getting_started; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.chrome.ChromeDriver; | ||
|
||
import java.time.Duration; | ||
|
||
public class FirstScript { | ||
public static void main(String[] args) { | ||
WebDriver driver = new ChromeDriver(); | ||
|
||
driver.get("https://www.selenium.dev/selenium/web/web-form.html"); | ||
|
||
driver.getTitle(); | ||
|
||
driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500)); | ||
|
||
WebElement textBox = driver.findElement(By.name("my-text")); | ||
WebElement submitButton = driver.findElement(By.cssSelector("button")); | ||
|
||
textBox.sendKeys("Selenium"); | ||
submitButton.click(); | ||
|
||
WebElement message = driver.findElement(By.id("message")); | ||
message.getText(); | ||
|
||
driver.quit(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
examples/java/src/test/java/dev/selenium/interactions/SavingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package dev.selenium.interactions; | ||
|
||
import dev.selenium.BaseChromeTest; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.NoSuchElementException; | ||
import org.openqa.selenium.print.PrintOptions; | ||
import org.openqa.selenium.remote.RemoteWebDriver; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.util.Base64; | ||
|
||
public class SavingTest extends BaseChromeTest { | ||
@Test | ||
public void prints() throws IOException { | ||
driver.get("https://www.selenium.dev"); | ||
|
||
String content = ((RemoteWebDriver) driver).print(new PrintOptions()).getContent(); | ||
byte[] bytes = Base64.getDecoder().decode(content); | ||
Files.write(Paths.get("selenium.pdf"), bytes); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.common.by import By | ||
|
||
driver = webdriver.Chrome() | ||
|
||
driver.get("https://www.selenium.dev/selenium/web/web-form.html") | ||
|
||
title = driver.title | ||
|
||
driver.implicitly_wait(0.5) | ||
|
||
text_box = driver.find_element(by=By.NAME, value="my-text") | ||
submit_button = driver.find_element(by=By.CSS_SELECTOR, value="button") | ||
|
||
text_box.send_keys("Selenium") | ||
submit_button.click() | ||
|
||
message = driver.find_element(by=By.ID, value="message") | ||
text = message.text | ||
|
||
driver.quit() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'selenium-webdriver' | ||
|
||
driver = Selenium::WebDriver.for :chrome | ||
|
||
driver.get('https://www.selenium.dev/selenium/web/web-form.html') | ||
|
||
driver.title | ||
|
||
driver.manage.timeouts.implicit_wait = 500 | ||
|
||
text_box = driver.find_element(name: 'my-text') | ||
submit_button = driver.find_element(tag_name: 'button') | ||
|
||
text_box.send_keys('Selenium') | ||
submit_button.click | ||
|
||
message = driver.find_element(id: 'message') | ||
message.text | ||
|
||
driver.quit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
=