Tuesday, 31 October 2017

Run Selenium Grid On Firefox Browser

Exported from Notepad++
package com.seleniumGrid; import java.net.MalformedURLException; import java.net.URL; import java.util.concurrent.TimeUnit; import org.openqa.selenium.Platform; import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; public class RunSeleniumGridOnFirefox { WebDriver driver; String nodeUrl = "http://192.168.3.12:1712/wd/hub"; @BeforeClass public void setUp() { try { DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setBrowserName("firefox"); capabilities.setPlatform(Platform.WINDOWS); driver = new RemoteWebDriver(new URL(nodeUrl), capabilities); } catch (MalformedURLException e) { e.printStackTrace(); } } @Test public void testSeleniumGridOnFirefox() { try { driver.manage().deleteAllCookies(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.manage().timeouts().pageLoadTimeout(35, TimeUnit.SECONDS); driver.get("https://seleniumcodeexample.blogspot.in"); System.out.println("Title Name is : " + driver.getTitle()); } catch (Exception e) { e.printStackTrace(); } } @AfterClass public void tearDown() throws InterruptedException { Thread.sleep(2000); driver.quit(); } }

No comments:

Post a Comment

Code Example - File Download By Robot Class In Firefox Browser

Exported from Notepad++ package com . practiceCode ; import java . awt . AWTException ; import java . awt . Robot ; import j...