{"id":198,"date":"2020-03-29T16:54:23","date_gmt":"2020-03-29T14:54:23","guid":{"rendered":"https:\/\/nissel.it\/?p=198"},"modified":"2021-04-05T07:55:13","modified_gmt":"2021-04-05T05:55:13","slug":"einrichten-von-selenium","status":"publish","type":"post","link":"https:\/\/nissel.it\/index.php\/2020\/03\/29\/einrichten-von-selenium\/","title":{"rendered":"Einrichten von Selenium"},"content":{"rendered":"\n<p>In Intellij ein neues Java-Gradle Projekt erstellen.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"563\" height=\"412\" src=\"https:\/\/nissel.it\/wp-content\/uploads\/2020\/03\/01-selenium.png\" alt=\"\" class=\"wp-image-199\" srcset=\"https:\/\/nissel.it\/wp-content\/uploads\/2020\/03\/01-selenium.png 563w, https:\/\/nissel.it\/wp-content\/uploads\/2020\/03\/01-selenium-300x220.png 300w\" sizes=\"auto, (max-width: 563px) 100vw, 563px\" \/><\/figure>\n\n\n\n<!--more-->\n\n\n\n<p>Anpassungen an die build.gradle Datei f\u00fcr Java 11 und Junit 5 mit selenium 3.141<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>plugins {\n    id 'java'\n    id 'idea'\n}\n\ngroup 'it.nissel'\nversion '1.0-SNAPSHOT'\n\nsourceCompatibility = 11\ntargetCompatibility = 11\n\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    testImplementation('org.junit.jupiter:junit-jupiter:5.6.1')\n    testImplementation('org.seleniumhq.selenium:selenium-java:3.141.59')\n}\n\ntest {\n    useJUnitPlatform()\n    testLogging {\n        events \"passed\", \"skipped\", \"failed\"\n    }\n}<\/code><\/pre>\n\n\n\n<p>Im N\u00e4chsten Schritt kann ein minimaler Test gestartet werden:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import org.junit.jupiter.api.Test;\nimport org.openqa.selenium.chrome.ChromeDriver;\n\npublic class LoginTest {\n\n    @Test\n    public void testShowLogin() {\n        new ChromeDriver();\n    }\n}<\/code><\/pre>\n\n\n\n<p>Beim ausf\u00fchren des Test schl\u00e4gt das erzeugen des ChromeDrivers fehl, da dieser noch nicht installiert ist. In der Fehlermeldung bekommt man aber direkt ein Link zu den aktuellen Releases. Hier muss der Treiber passend zum aktuellen Browser verwendet werden. Es ist zu empfehlen den Treiber direkt ins das Projekt mit abzulegen und die Versionsnummer in den Dateinamen zu \u00fcbernehmen. Danach muss nur der Pfad zum Treiber angegeben werden.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@BeforeAll\n    private static void prepare() {\n        System.setProperty(\"webdriver.chrome.driver\", \"driver\/chromedriver-80.0.3987.106\");\n    }<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Umgebung<\/h2>\n\n\n\n<p>Ubuntu 18.04<br>Intellij 2019.3<br>Java 11<br>Gradle 5.2.1<br>Junit 5.6.1<br>selenium 3.141<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Links<\/h2>\n\n\n\n<figure class=\"wp-block-embed-wordpress wp-block-embed is-type-wp-embed is-provider-international-testing-board\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"brMS4NKf8d\"><a href=\"https:\/\/www.testing-board.com\/selenium-webdriver-tutorial-1-grundlagen-testautomatisierung-wordpress-und-basis-testframework\/\">Selenium\u00a0Webdriver Tutorial 1: Grundlagen Testautomatisierung WordPress und Basis Testframework<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8222;Selenium\u00a0Webdriver Tutorial 1: Grundlagen Testautomatisierung WordPress und Basis Testframework&#8220; &#8212; Testing-Board.com\" src=\"https:\/\/www.testing-board.com\/selenium-webdriver-tutorial-1-grundlagen-testautomatisierung-wordpress-und-basis-testframework\/embed\/#?secret=BNaxI91bkA#?secret=brMS4NKf8d\" data-secret=\"brMS4NKf8d\" width=\"525\" height=\"296\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><figcaption>Anleitung f\u00fcr Selenium mit Java und Eclipse<\/figcaption><\/figure>\n\n\n\n<p><a href=\"https:\/\/github.com\/junit-team\/junit5-samples\/blob\/r5.6.1\/junit5-jupiter-starter-gradle\/build.gradle\">https:\/\/github.com\/junit-team\/junit5-samples\/blob\/r5.6.1\/junit5-jupiter-starter-gradle\/build.gradle<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/chromedriver.storage.googleapis.com\/index.html\">https:\/\/chromedriver.storage.googleapis.com\/index.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Intellij ein neues Java-Gradle Projekt erstellen.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[16,10],"class_list":["post-198","post","type-post","status-publish","format-standard","hentry","category-softwareentwicklung","tag-java","tag-selenium"],"_links":{"self":[{"href":"https:\/\/nissel.it\/index.php\/wp-json\/wp\/v2\/posts\/198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nissel.it\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nissel.it\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nissel.it\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nissel.it\/index.php\/wp-json\/wp\/v2\/comments?post=198"}],"version-history":[{"count":3,"href":"https:\/\/nissel.it\/index.php\/wp-json\/wp\/v2\/posts\/198\/revisions"}],"predecessor-version":[{"id":376,"href":"https:\/\/nissel.it\/index.php\/wp-json\/wp\/v2\/posts\/198\/revisions\/376"}],"wp:attachment":[{"href":"https:\/\/nissel.it\/index.php\/wp-json\/wp\/v2\/media?parent=198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nissel.it\/index.php\/wp-json\/wp\/v2\/categories?post=198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nissel.it\/index.php\/wp-json\/wp\/v2\/tags?post=198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}