{"id":4729,"date":"2018-10-10T14:45:14","date_gmt":"2018-10-10T14:45:14","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=4729"},"modified":"2024-12-14T05:42:31","modified_gmt":"2024-12-14T05:42:31","slug":"how-to-run-selenium-tests-on-opera-browser","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/how-to-run-selenium-tests-on-opera-browser\/","title":{"rendered":"How to run Selenium tests on Opera browser"},"content":{"rendered":"<h1>How to run Selenium tests on the Opera browser<\/h1>\n<p>In this tutorial, let&#8217;s learn the steps involved to run Selenium tests on Opera Browser. Opera is one of the most popular web browsers. Selenium automates a <a href=\"https:\/\/www.testingdocs.com\/questions\/what-is-a-web-browser\/\">web browser.<\/a>\u00a0 First things first, download and install Opera browser on the Windows test machine.<\/p>\n<p>The steps to download and install are listed here:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.testingdocs.com\/questions\/how-to-download-opera-browser-on-windows\/\">Download Opera Browser<\/a><\/li>\n<\/ul>\n<h2>Download Opera Driver<\/h2>\n<p>Navigate to the following URL:<\/p>\n<ul>\n<li><strong>https:\/\/www.selenium.dev\/downloads\/<\/strong><\/li>\n<\/ul>\n<p>Expand Browsers accordion.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4731\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Opera-Driver-Link.png\" alt=\"Opera Driver\" width=\"1675\" height=\"908\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Opera-Driver-Link.png 1675w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Opera-Driver-Link-300x163.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Opera-Driver-Link-1024x555.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Opera-Driver-Link-768x416.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Opera-Driver-Link-1536x833.png 1536w\" sizes=\"auto, (max-width: 1675px) 100vw, 1675px\" \/><\/p>\n<p>Click on the documentation link.<\/p>\n<p>Download the Opera driver from the link.<\/p>\n<ul>\n<li><strong>https:\/\/github.com\/operasoftware\/operachromiumdriver\/releases<\/strong><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4745\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/opera-driver-download.png\" alt=\"opera driver download\" width=\"1735\" height=\"903\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/opera-driver-download.png 1735w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/opera-driver-download-300x156.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/opera-driver-download-1024x533.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/opera-driver-download-768x400.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/opera-driver-download-1536x799.png 1536w\" sizes=\"auto, (max-width: 1735px) 100vw, 1735px\" \/><\/h3>\n<h2>Sample Test<\/h2>\n<ul>\n<li>Open an IDE tool like Eclipse or IntelliJ IDEA. Create a Test Project.<\/li>\n<li>Copy the opera driver under the project directory.<\/li>\n<li>Create a Test class.<\/li>\n<li>Add the following test code to the test class.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<pre>import java.util.concurrent.TimeUnit;\r\nimport org.openqa.selenium.WebDriver;\r\nimport org.openqa.selenium.opera.OperaDriver;\r\nimport org.testng.Assert;\r\nimport org.testng.annotations.AfterClass;\r\nimport org.testng.annotations.BeforeClass;\r\nimport org.testng.annotations.Test;\r\n\r\npublic class OperaSeleniumTest {\r\n\r\n    private WebDriver driver;\r\n\r\n    @Test\r\n    public void sampleTest() {\r\n        driver.get(\"https:\/\/www.google.com\");\r\n        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);\r\n        Assert.assertEquals(driver.getTitle(), \"Google\", \"I'm verifying window title here in this test\");\r\n    }\r\n\r\n    @BeforeClass\r\n    public void beforeClass() {\r\n        System.setProperty(\"webdriver.opera.driver\", \"operadriver.exe\");\r\n        driver = new OperaDriver();\r\n    }\r\n\r\n    @AfterClass\r\n    public void afterClass() {\r\n        if(driver != null)\r\n        {\r\n            driver.quit();\r\n        }\r\n    }\r\n}\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>The following code sets the opera driver path. Specify the path to the driver on your machine.<\/p>\n<p><em> System.setProperty(&#8220;webdriver.opera.driver&#8221;, &#8220;&lt;path to the operadriver.exe&gt;&#8221;);<\/em><\/p>\n<p>We can instantiate the driver by using the following code line:<\/p>\n<p>WebDriver driver = new OperaDriver();<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4744\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Selenium-Test-Opera-Browser.png\" alt=\"Selenium Test Opera Browser\" width=\"1520\" height=\"981\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Selenium-Test-Opera-Browser.png 1520w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Selenium-Test-Opera-Browser-300x194.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Selenium-Test-Opera-Browser-1024x661.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Selenium-Test-Opera-Browser-768x496.png 768w\" sizes=\"auto, (max-width: 1520px) 100vw, 1520px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Run the test code. The test should open the Google search page on the Opera browser and run the sample test.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to run Selenium tests on the Opera browser In this tutorial, let&#8217;s learn the steps involved to run Selenium tests on Opera Browser. Opera is one of the most popular web browsers. Selenium automates a web browser.\u00a0 First things first, download and install Opera browser on the Windows test machine. The steps to download [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[185],"tags":[214],"class_list":["post-4729","post","type-post","status-publish","format-standard","hentry","category-selenium","tag-selenium","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/4729","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=4729"}],"version-history":[{"count":16,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/4729\/revisions"}],"predecessor-version":[{"id":26457,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/4729\/revisions\/26457"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=4729"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=4729"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=4729"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}