{"id":90,"date":"2016-02-03T21:02:26","date_gmt":"2016-02-03T21:02:26","guid":{"rendered":"http:\/\/eitzen.at\/?p=90"},"modified":"2016-04-29T08:50:10","modified_gmt":"2016-04-29T08:50:10","slug":"how-to-develop-your-own-plugins-for-seleniet","status":"publish","type":"post","link":"https:\/\/eitzen.at\/index.php\/how-to-develop-your-own-plugins-for-seleniet\/","title":{"rendered":"How to develop your own Plugins for Seleniet"},"content":{"rendered":"<h2>Java File<\/h2>\n<p>Create a java file in the seleniet root folder, like e.g. this one:<\/p>\n<pre><span style=\"color: #808080;\">package et.seleniet.plugins.ext;<\/span>\r\n<span style=\"color: #808080;\">import java.util.List;<\/span>\r\n<span style=\"color: #808080;\">import org.openqa.selenium.Alert;<\/span>\r\n<span style=\"color: #808080;\">import org.openqa.selenium.NoSuchElementException;<\/span>\r\n<span style=\"color: #808080;\">import org.openqa.selenium.WebElement;<\/span>\r\n<span style=\"color: #808080;\">import et.seleniet.api.AbortException;<\/span>\r\n<span style=\"color: #808080;\">import et.seleniet.api.ElementIndependentKeywordPlugin;<\/span>\r\n<span style=\"color: #808080;\">import et.seleniet.api.Seleniet;<\/span>\r\n<span style=\"color: #808080;\">import et.seleniet.api.Log;<\/span>\r\n\r\n<span style=\"color: #808080;\">public class DummyExamplePlugin extends ElementIndependentKeywordPlugin {<\/span>\r\n\r\n<span style=\"color: #808080;\"> public void execute(Seleniet driver, WebElement elem, String page, List&lt;String&gt; lineArgs, List&lt;String&gt; tcParams)<\/span>\r\n<span style=\"color: #808080;\"> throws NoSuchElementException, AbortException {<\/span>\r\n<span style=\"color: #808080;\">   try {<\/span>\r\n<span style=\"color: #808080;\">     Alert alert = driver.webDriver().switchTo().alert();<\/span>\r\n<span style=\"color: #808080;\">     if (alert != null) {<\/span>\r\n<span style=\"color: #808080;\">       alert.accept();<\/span>\r\n<span style=\"color: #808080;\">     }<\/span>\r\n<span style=\"color: #808080;\">   } catch (Exception e) {<\/span>\r\n<span style=\"color: #808080;\">     \/\/ all fine<\/span>\r\n<span style=\"color: #808080;\">   }<\/span>\r\n<span style=\"color: #808080;\">  }<\/span>\r\n<span style=\"color: #808080;\">}<\/span><\/pre>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"alignright size-medium wp-image-171\" src=\"https:\/\/i0.wp.com\/eitzen.at\/wp-content\/uploads\/2016\/02\/Warning_icon.png?resize=1%2C1\" alt=\"Warning_icon\" width=\"1\" height=\"1\" \/><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"173\" data-permalink=\"https:\/\/eitzen.at\/index.php\/how-to-develop-your-own-plugins-for-seleniet\/warning_icon\/\" data-orig-file=\"https:\/\/i0.wp.com\/eitzen.at\/wp-content\/uploads\/2016\/02\/Warning_icon.png?fit=600%2C500&amp;ssl=1\" data-orig-size=\"600,500\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Warning_icon\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/eitzen.at\/wp-content\/uploads\/2016\/02\/Warning_icon.png?fit=600%2C500&amp;ssl=1\" class=\" wp-image-173 alignleft\" src=\"https:\/\/i0.wp.com\/eitzen.at\/wp-content\/uploads\/2016\/02\/Warning_icon-300x250.png?resize=79%2C66\" alt=\"Warning_icon\" width=\"79\" height=\"66\" srcset=\"https:\/\/i0.wp.com\/eitzen.at\/wp-content\/uploads\/2016\/02\/Warning_icon.png?resize=300%2C250&amp;ssl=1 300w, https:\/\/i0.wp.com\/eitzen.at\/wp-content\/uploads\/2016\/02\/Warning_icon.png?w=600&amp;ssl=1 600w\" sizes=\"auto, (max-width: 79px) 100vw, 79px\" \/><\/p>\n<p>Make SURE that your class name ends with &#8220;Plugin&#8221; and that you derive from &#8220;ElementIndependentKeywordPlugin&#8221; else it won&#8217;t be found by Seleniet!<\/p>\n<h2><\/h2>\n<h2>Compile<\/h2>\n<p>run the command below to compile your source code<\/p>\n<h5>Linux<\/h5>\n<pre><span style=\"color: #808080;\">javac -cp seleniet-exec*.jar:lib\/* DummyExamplePlugin.java<\/span><\/pre>\n<h5>Windows<\/h5>\n<pre><span style=\"color: #808080;\">javac -cp seleniet-exec*.jar;lib\\* DummyExamplePlugin.java<\/span><\/pre>\n<h2>Jar it<\/h2>\n<p>After successful compilation create the folders:<\/p>\n<pre><span style=\"color: #808080;\">mkdir et\/seleniet\/plugins\/ext<\/span><\/pre>\n<p>and move the class file into the ext subfolder. Now jar the class file and\u00a0move\u00a0the\u00a0jar\u00a0file to the lib\/ext folder (if it doesnt exist create it!).<\/p>\n<pre><span style=\"color: #808080;\">jar cvf \u00a0seleniet-extplugin.jar et<\/span><\/pre>\n<pre><span style=\"color: #808080;\">mv seleniet-extplugin.jar lib\/ext<\/span><\/pre>\n<p>For Windows please use analog commands on the command line or use Tools such as Winzip to create the Java Archive.<\/p>\n<h2>Run it<\/h2>\n<p>Test it by starting seleniet with<\/p>\n<pre><span style=\"color: #808080;\">.\/seleniet.sh run --dev Development.xls zephyr --url http:\/\/localhost<\/span><\/pre>\n<p>Check the console ouptut and you will see two lines amongst many others<\/p>\n<pre>...\r\n...\r\n[.....] - INFORMATION - PLUGIN Found resource URL for package et.seleniet.plugins.ext: jar:file: .....\r\n...\r\n...\r\n...\r\n[.....] - INFORMATION - PLUGIN KEYWORD 'dummyexample' -&gt; 'et.seleniet.plugins.ext.DummyExamplePlugin' \r\n...\r\n...<\/pre>\n<p>This indicates that Seleniet has successfully detected your plugin and you can use it in your test cases.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java File Create a java file in the seleniet root folder, like e.g. this one: package et.seleniet.plugins.ext; import java.util.List; import org.openqa.selenium.Alert; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebElement; import et.seleniet.api.AbortException; import et.seleniet.api.ElementIndependentKeywordPlugin; import et.seleniet.api.Seleniet; import et.seleniet.api.Log; public class DummyExamplePlugin extends ElementIndependentKeywordPlugin { public void execute(Seleniet driver, WebElement elem, String page, List&lt;String&gt; lineArgs, List&lt;String&gt; tcParams) throws NoSuchElementException, AbortException { <a href=\"https:\/\/eitzen.at\/index.php\/how-to-develop-your-own-plugins-for-seleniet\/\" rel=\"nofollow\"><span class=\"sr-only\">Read more about How to develop your own Plugins for Seleniet<\/span>[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":74,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3],"tags":[5],"class_list":["post-90","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-job","tag-seleniet"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/eitzen.at\/wp-content\/uploads\/2016\/01\/logo-text.png?fit=751%2C235&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p88Djt-1s","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/eitzen.at\/index.php\/wp-json\/wp\/v2\/posts\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eitzen.at\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eitzen.at\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eitzen.at\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eitzen.at\/index.php\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":4,"href":"https:\/\/eitzen.at\/index.php\/wp-json\/wp\/v2\/posts\/90\/revisions"}],"predecessor-version":[{"id":175,"href":"https:\/\/eitzen.at\/index.php\/wp-json\/wp\/v2\/posts\/90\/revisions\/175"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/eitzen.at\/index.php\/wp-json\/wp\/v2\/media\/74"}],"wp:attachment":[{"href":"https:\/\/eitzen.at\/index.php\/wp-json\/wp\/v2\/media?parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eitzen.at\/index.php\/wp-json\/wp\/v2\/categories?post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eitzen.at\/index.php\/wp-json\/wp\/v2\/tags?post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}