Skip to content

Create new Getting Started page for Running Tests #1479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions examples/dotnet/HelloSelenium.cs
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 examples/dotnet/SeleniumDocs/GettingStarted/FirstScript.cs
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
namespace SeleniumDocs.GettingStarted
{
[TestClass]
public class FirstScriptTest
public class UsingSeleniumTest
{

[TestMethod]
public void ChromeSession()
public void EightComponents()
{
IWebDriver driver = new ChromeDriver();

Expand Down
16 changes: 0 additions & 16 deletions examples/dotnet/SeleniumDocs/Hello/HelloSelenium.cs

This file was deleted.

3 changes: 2 additions & 1 deletion examples/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ repositories {

dependencies {
testImplementation 'org.seleniumhq.selenium:selenium-java:4.13.0'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
testImplementation 'org.seleniumhq.selenium:selenium-http-jdk-client:4.13.0'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
}

test {
Expand Down
32 changes: 11 additions & 21 deletions examples/java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@
<version>1.0.0</version>

<properties>
<maven-surefire-plugin.version>3.0.0-M7</maven-surefire-plugin.version>
<java.version>8</java.version>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.source>${java.version}</maven.compiler.source>
<project.encoding>UTF-8</project.encoding>
<project.build.sourceEncoding>${project.encoding}</project.build.sourceEncoding>
<project.reporting.outputEncoding>${project.encoding}</project.reporting.outputEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
Expand All @@ -35,19 +31,14 @@
<version>4.13.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.5</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.4.6</version>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-http-jdk-client</artifactId>
<version>4.13.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.2</version>
<version>5.10.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -57,12 +48,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<version>3.1.2</version>
<configuration>
<includes>
<include>**/*Test.java</include>
<include>**/*Example.java</include>
</includes>
<systemPropertyVariables>
<webdriver.http.factory>jdk-http-client</webdriver.http.factory>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
Expand Down
16 changes: 0 additions & 16 deletions examples/java/src/main/resources/logback.xml

This file was deleted.

14 changes: 10 additions & 4 deletions examples/java/src/test/java/dev/selenium/browsers/ChromeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Pdf;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.chromium.ChromiumDriverLogLevel;
import org.openqa.selenium.print.PrintOptions;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Base64;
import java.util.regex.Pattern;

public class ChromeTest {
Expand All @@ -35,9 +36,14 @@ public void quit() {
}

@Test
public void basicOptions() {
public void basicOptions() throws IOException {
ChromeOptions options = new ChromeOptions();
driver = new ChromeDriver(options);
driver.get("https://www.selenium.dev");

String content = driver.print(new PrintOptions()).getContent();
byte[] bytes = Base64.getDecoder().decode(content);
Files.write(Paths.get("printed.pdf"), bytes);
}

@Test
Expand Down
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

public class FirstScriptTest {
public class UsingSeleniumTest {

@Test
public void eightComponents() {
Expand Down
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);
}
}
21 changes: 21 additions & 0 deletions examples/python/tests/getting_started/first_script.py
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()
20 changes: 20 additions & 0 deletions examples/ruby/spec/getting_started/first_script.rb
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper'

RSpec.describe 'First Script' do
RSpec.describe 'Using Selenium' do
it 'uses eight components' do
driver = Selenium::WebDriver.for :chrome

Expand Down
5 changes: 1 addition & 4 deletions website_and_docs/content/documentation/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ a browser. You can find a more comprehensive example in [Writing your first Sele
{{< gh-codeblock path="/examples/python/tests/hello/hello_selenium.py" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Hello/HelloSelenium.cs" >}}
{{< gh-codeblock path="/examples/dotnet/HelloSelenium.cs" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/hello/hello_selenium_spec.rb" >}}
Expand All @@ -59,6 +59,3 @@ You should continue on to [Getting Started]({{< ref "webdriver/getting_started"
to understand how you can install Selenium and successfully use it as a test
automation tool, and scaling simple tests like this to run in large, distributed
environments on multiple browsers, on several different operating systems.



5 changes: 1 addition & 4 deletions website_and_docs/content/documentation/_index.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Seleniumの中核は[WebDriver]({{< ref "/webdriver.md" >}})であり、様々
{{< gh-codeblock path="/examples/python/tests/hello/hello_selenium.py" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Hello/HelloSelenium.cs" >}}
{{< gh-codeblock path="/examples/dotnet/HelloSelenium.cs" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/hello/hello_selenium_spec.rb" >}}
Expand All @@ -48,6 +48,3 @@ Seleniumが適切なツールであるかどうかを判断してください。
Seleniumをインストールし、テスト自動化ツールとして正常に使用する方法を理解し、
このような単純なテストをスケーリングして、複数のブラウザー、
複数の異なるオペレーティングシステムの大規模な分散環境で実行する必要があります。



2 changes: 1 addition & 1 deletion website_and_docs/content/documentation/_index.pt-br.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ navegadores. Aqui está uma das instruções mais simples que você pode fazer:
{{< gh-codeblock path="/examples/python/tests/hello/hello_selenium.py" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Hello/HelloSelenium.cs" >}}
{{< gh-codeblock path="/examples/dotnet/HelloSelenium.cs" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/hello/hello_selenium_spec.rb" >}}
Expand Down
3 changes: 1 addition & 2 deletions website_and_docs/content/documentation/_index.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Selenium 的核心是 [WebDriver]({{< ref "/webdriver.md" >}}),这是一个编
{{< gh-codeblock path="/examples/python/tests/hello/hello_selenium.py" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< gh-codeblock path="/examples/dotnet/SeleniumDocs/Hello/HelloSelenium.cs" >}}
{{< gh-codeblock path="/examples/dotnet/HelloSelenium.cs" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="/examples/ruby/spec/hello/hello_selenium_spec.rb" >}}
Expand All @@ -56,4 +56,3 @@ Selenium 的核心是 [WebDriver]({{< ref "/webdriver.md" >}}),这是一个编
在大型分布式环境,
以及不同操作系统上的环境上
运行多个浏览器的测试.

Loading