Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
azharuddin
azharuddin
Active particpant
Active particpant
Posts : 13
Join date : 2017-02-03
Age : 31
Location : Hyderabad
https://jovisoftsolutions.com

How to use WebDriver Backed Selenium Empty How to use WebDriver Backed Selenium

Thu Mar 01, 2018 12:40 pm

[size=30]WebDriver Backed Selenium[/size]



The Java version of Webdriver provides an implementation of the Selenium-RC API. This means that you can use the underlying WebDriver technology using the Selenium-RC API or Selenium with Python Training. This is primarily provided for backwards compatiblity. It allows those who have existing test suites using the Selenium-RC API to use WebDriver under the covers. It’s provided to help ease of the migration path to Selenium-Web driver.
Sample Backed web driver script looks like this:
package webone;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.firefox.FirefoxDriver;
import com.thoughtworks.selenium.SeleneseTestCase;
Check out Snowflake Training

import com.thoughtworks.selenium.Selenium;
@SuppressWarnings("deprecation")
public class BackedSelenium extends SeleneseTestCase {
//web driver ??here we are declaring the browser
WebDriver driver = new FirefoxDriver();
@Before
public void setUp() throws Exception {
String baseUrl = "https://www.google.co.in/";
selenium = new WebDriverBackedSelenium(driver, baseUrl);
}

@TEST
public void testBackedSelenium() throws Exception {
//This is using selenium
selenium.open("/");
selenium.click("id=gbi5");
selenium.click("id=gmlas");
selenium.waitForPageToLoad("30000");
selenium.type("name=as_q", "test");
//Here we are using Webdriver
driver.findElement(By.id("as_oq1")).sendKeys("naga");

driver.findElement(By.id("as_oq2")).sendKeys("Webdriver");
Thread.sleep(5000);
}

@After
public void tearDown() throws Exception {
selenium.stop();
}
}
By using the above format, you can use both the Selenium API and Web driver API…
Interested in mastering Selenium Training? Enroll now for FREE demo on Selenium Training.

[size=30]Run WebDriver Scripts in Chrome[/size]



We run the Selenium Webdriver programs in Google Chrome web browser to perform automation testing.
Below theory explains you how to run your webdriver script in google chrome..
Firefox Browser:
driver=new FirefoxDriver();---it will work and will launch your firefox browser,
Google Chrome:
driver= new Chromedriver() --- it will throw an error.
Error:
FAILED CONFIGURATION: @BeforeClass beforeClass
java.lang.IllegalStateException:
The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information.
To overcome this, we need to download the chrome driver.exe and we have to specify the path of a chrome driver in the script
Download path:
https://code.google.com/p/chromedriver/downloads/list take the latest exe file.
How to use WebDriver Backed Selenium Just(2)
Save the chrome driver in a folder and you need to specify the path of a driver in your web driver script.
Below is the Sample code:
package testng;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class ChromedriverTest {
111
public WebDriver driver;

@BeforeClass
public void beforeClass() {
// Create chrome driver instance...
System.setProperty("webdriver.chrome.driver", "C:xxxJarchromedriver.exe");

driver=new ChromeDriver();
}

@TEST
public void testChromedriverTest() throws Exception {
driver.navigate().to("https://bing.com");
Thread.sleep(5000);
}

@AfterClass
public void afterClass() {
driver.quit();

}
}
Use the above code for your script which will run in Google chrome.
Back to top
Permissions in this forum:
You cannot reply to topics in this forum