How to use WebDriverFactory class of com.paypal.selion.internal.platform.grid.browsercapabilities package

Best SeLion code snippet using com.paypal.selion.internal.platform.grid.browsercapabilities.WebDriverFactory

Source:WebTestSession.java Github

copy

Full Screen

...18import org.testng.IInvokedMethod;19import com.paypal.selion.annotations.WebTest;20import com.paypal.selion.configuration.Config;21import com.paypal.selion.configuration.Config.ConfigProperty;22import com.paypal.selion.internal.platform.grid.browsercapabilities.WebDriverFactory;23import com.paypal.selion.internal.utils.InvokedMethodInformation;24import com.paypal.selion.logger.SeLionLogger;25import com.paypal.selion.platform.grid.Grid;26import com.paypal.selion.platform.grid.RemoteNodeInformation;27import com.paypal.test.utilities.logging.SimpleLogger;28/**29 * A class for loading and representing the {@link WebTest} annotation parameters. Also performs sanity checks.30 */31public class WebTestSession extends AbstractTestSession {32 private String browser = "";33 private int browserHeight;34 private int browserWidth;35 private static final SimpleLogger logger = SeLionLogger.getLogger();36 WebTestSession() {37 super();38 }39 /**40 * Call this to initialize the {@link WebTestSession} object from the TestNG {@link IInvokedMethod}41 *42 * @param method43 * - the TestNG {@link IInvokedMethod}44 *45 */46 @Override47 public void initializeTestSession(InvokedMethodInformation method) {48 this.initTestSession(method);49 WebTest webTestAnnotation = method.getAnnotation(WebTest.class);50 // check class has webtest annotation (i.e. using shared sessions)51 if (webTestAnnotation == null) {52 webTestAnnotation = method.getActualMethod().getDeclaringClass().getAnnotation(WebTest.class);53 }54 // Setting the browser value55 this.browser = getLocalConfigProperty(ConfigProperty.BROWSER);56 if (webTestAnnotation != null) {57 if (StringUtils.isNotBlank(webTestAnnotation.browser())) {58 this.browser = webTestAnnotation.browser();59 }60 if (webTestAnnotation.browserHeight() > 0 && webTestAnnotation.browserWidth() > 0) {61 this.browserHeight = webTestAnnotation.browserHeight();62 this.browserWidth = webTestAnnotation.browserWidth();63 } else {64 warnUserOfInvalidBrowserDimensions(webTestAnnotation);65 }66 initializeAdditionalCapabilities(method);67 initializeAdditionalCapabilities(webTestAnnotation.additionalCapabilities());68 initializeAdditionalCapabilities(webTestAnnotation.additionalCapabilitiesBuilders());69 }70 }71 private void warnUserOfInvalidBrowserDimensions(WebTest webTestAnnotation) {72 if (webTestAnnotation.browserHeight() < 0 && webTestAnnotation.browserWidth() < 0) {73 logger.info("The parameters provided in WebTest annotation are less than zero. Ignoring them.");74 }75 if (webTestAnnotation.browserHeight() == 0 && webTestAnnotation.browserWidth() == 0) {76 logger.fine("No parameters for browser dimensions were provided.");77 } else if (webTestAnnotation.browserHeight() == 0) {78 logger.info("The height was not provided ignoring width parameter.");79 } else if (webTestAnnotation.browserWidth() == 0) {80 logger.info("The width was not provided ignoring height parameter.");81 }82 }83 /**84 * @return the browser configured for the test method85 */86 public final String getBrowser() {87 logger.entering();88 // By now we would have already set the browser flavor from the local config as part of the89 // initializeTestSession90 // method. So lets check if its still blank and if yes, we default it to the global config value.91 if (StringUtils.isBlank(this.browser)) {92 this.browser = Config.getConfigProperty(ConfigProperty.BROWSER);93 }94 // All of our browser values need to start with the magic char "*"95 if (!StringUtils.startsWith(this.browser, "*")) {96 this.browser = "*".concat(this.browser);97 }98 logger.exiting(this.browser);99 return this.browser;100 }101 /**102 * @return the height of the Browser window that will be spawned103 */104 public final int getBrowserHeight() {105 if (this.browserHeight == 0 || this.browserWidth == 0) {106 String height = getLocalConfigProperty(ConfigProperty.BROWSER_HEIGHT);107 if (StringUtils.isNotBlank(height)) {108 this.browserHeight = Integer.parseInt(height);109 }110 }111 return (this.browserHeight);112 }113 /**114 * @return the width of the browser window that will be spawned115 */116 public final int getBrowserWidth() {117 if (this.browserHeight == 0 || this.browserWidth == 0) {118 String width = getLocalConfigProperty(ConfigProperty.BROWSER_WIDTH);119 if (StringUtils.isNotBlank(width)) {120 this.browserWidth = Integer.parseInt(width);121 }122 }123 return (this.browserWidth);124 }125 private boolean runLocally() {126 return Boolean.parseBoolean(Config.getConfigProperty(ConfigProperty.SELENIUM_RUN_LOCALLY));127 }128 private void createSession() {129 logger.entering();130 BrowserFlavors flavor = BrowserFlavors.getBrowser(getBrowser());131 RemoteWebDriver driver = WebDriverFactory.createInstance(flavor);132 if (!runLocally()) {133 String hostName = Config.getConfigProperty(ConfigProperty.SELENIUM_HOST);134 int port = Integer.parseInt(Config.getConfigProperty(ConfigProperty.SELENIUM_PORT));135 RemoteNodeInformation node = Grid.getRemoteNodeInfo(hostName, port, driver.getSessionId());136 if (node != null) {137 logger.info(node.toString());138 }139 }140 Grid.getThreadLocalWebDriver().set(driver);141 logger.exiting();142 }143 @Override144 public void startSession() {145 createSession();...

Full Screen

Full Screen

Source:WebDriverFactory.java Github

copy

Full Screen

...31 * This factory class is responsible for providing the framework with a {@link RemoteWebDriver} instance based on the32 * browser type.33 *34 */35public final class WebDriverFactory {36 private static SimpleLogger logger = SeLionLogger.getLogger();37 public static RemoteWebDriver createInstance() {38 return createInstance(BrowserFlavors.getBrowser(Grid.getWebTestSession().getBrowser()));39 }40 /**41 * @param browser enum that represents the browser flavor for which capabilities are being requested.42 * @return A {@link RemoteWebDriver} instance based on the browser type43 */44 public static RemoteWebDriver createInstance(BrowserFlavors browser) {45 DesiredCapabilities capability = null;46 RemoteWebDriver driver = null;47 switch (browser) {48 case FIREFOX:49 capability = new FireFoxCapabilitiesBuilder().createCapabilities();...

Full Screen

Full Screen

WebDriverFactory

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.WebDriver;2import com.paypal.selion.internal.platform.grid.browsercapabilities.WebDriverFactory;3public class 3 {4public static void main(String[] args) {5WebDriver driver = WebDriverFactory.getWebDriver();6driver.quit();7}8}9[firefox #0-0] INFO org.openqa.selenium.remote.DesiredCapabilities - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`10[firefox #0-0] INFO org.openqa.selenium.remote.DesiredCapabilities - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`11[firefox #0-0] INFO org.openqa.selenium.remote.DesiredCapabilities - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`12[firefox #0-0] INFO org.openqa.selenium.remote.DesiredCapabilities - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`13[firefox #0-0] INFO org.openqa.selenium.remote.DesiredCapabilities - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`14[firefox #0-0] INFO org.openqa.selenium.remote.DesiredCapabilities - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`15[firefox #0-0] INFO org.openqa.selenium.remote.DesiredCapabilities - Using `new FirefoxOptions()` is preferred to `

Full Screen

Full Screen

WebDriverFactory

Using AI Code Generation

copy

Full Screen

1package com.paypal.selion.internal.platform.grid.browsercapabilities;2import java.util.HashMap;3import java.util.Map;4import org.openqa.selenium.remote.DesiredCapabilities;5import com.paypal.selion.configuration.Config;6import com.paypal.selion.configuration.Config.ConfigProperty;7import com.paypal.selion.grid.servlets.transfer.SauceLabsCredentials;8import com.paypal.selion.internal.platform.grid.browsercapabilities.SauceCapabilitiesBuilder.SauceLabsAuthenticationException;9public class WebDriverFactory {10 private static final Map<String, DesiredCapabilities> CAPABILITIES_MAP = new HashMap<String, DesiredCapabilities>();11 private WebDriverFactory() {12 }13 * This method returns the {@link DesiredCapabilities} for the given browser type14 * - The browser type for which the {@link DesiredCapabilities} is required15 * @return The {@link DesiredCapabilities} for the given browser type16 public static DesiredCapabilities getCapabilities(String browser) {17 if (CAPABILITIES_MAP.containsKey(browser)) {18 return CAPABILITIES_MAP.get(browser);19 }20 DesiredCapabilities capabilities = null;21 if (browser.equalsIgnoreCase("firefox")) {22 capabilities = new FirefoxCapabilitiesBuilder().getCapabilities();23 } else if (browser.equalsIgnoreCase("chrome")) {24 capabilities = new ChromeCapabilitiesBuilder().getCapabilities();25 } else if (browser.equalsIgnoreCase("internet explorer")) {26 capabilities = new InternetExplorerCapabilitiesBuilder().getCapabilities();27 } else if (browser.equalsIgnoreCase("safari")) {28 capabilities = new SafariCapabilitiesBuilder().getCapabilities();29 } else if (browser.equalsIgnoreCase("iphone")) {30 capabilities = new IPhoneCapabilitiesBuilder().getCapabilities();31 } else if (browser.equalsIgnoreCase("ipad")) {32 capabilities = new IPadCapabilitiesBuilder().getCapabilities();33 } else if (browser.equalsIgnoreCase("android")) {34 capabilities = new AndroidCapabilitiesBuilder().getCapabilities();35 } else if (browser.equalsIgnoreCase("htmlunit")) {36 capabilities = new HtmlUnitCapabilitiesBuilder().getCapabilities();37 } else if (browser.equalsIgnoreCase("htmlunitwithjs")) {38 capabilities = new HtmlUnitWithJSCapabilitiesBuilder().getCapabilities();39 } else if (browser.equalsIgnoreCase("phantomjs")) {40 capabilities = new PhantomJSCapabilitiesBuilder().getCapabilities();41 } else if (browser.equalsIgnoreCase("sauce")) {42 String sauceUserName = Config.getConfigProperty(ConfigProperty.SELENIUM_SAUCELABS

Full Screen

Full Screen

WebDriverFactory

Using AI Code Generation

copy

Full Screen

1import com.paypal.selion.internal.platform.grid.browsercapabilities.WebDriverFactory;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.remote.DesiredCapabilities;4public class Test {5 public static void main(String[] args) {6 DesiredCapabilities capabilities = DesiredCapabilities.firefox();7 WebDriver driver = WebDriverFactory.getWebDriver(capabilities);8 System.out.println(driver.getTitle());9 }10}11import com.paypal.selion.internal.platform.grid.browsercapabilities.WebDriverFactory;12import org.openqa.selenium.WebDriver;13import org.openqa.selenium.remote.DesiredCapabilities;14public class Test {15 public static void main(String[] args) {16 DesiredCapabilities capabilities = DesiredCapabilities.operaBlink();17 WebDriver driver = WebDriverFactory.getWebDriver(capabilities);18 System.out.println(driver.getTitle());19 }20}21import com.paypal.selion.internal.platform.grid.browsercapabilities.WebDriverFactory;22import org.openqa.selenium.WebDriver;23import org.openqa.selenium.remote.DesiredCapabilities;24public class Test {25 public static void main(String[] args) {26 DesiredCapabilities capabilities = DesiredCapabilities.operaBlink();27 WebDriver driver = WebDriverFactory.getWebDriver(capabilities);28 System.out.println(driver.getTitle());29 }30}

Full Screen

Full Screen

WebDriverFactory

Using AI Code Generation

copy

Full Screen

1package com.paypal.selion.testcomponents;2import java.util.concurrent.TimeUnit;3import org.openqa.selenium.WebDriver;4import org.openqa.selenium.support.PageFactory;5import org.openqa.selenium.support.ui.WebDriverWait;6import org.testng.annotations.Test;7import com.paypal.selion.annotations.WebTest;8import com.paypal.selion.internal.platform.grid.browsercapabilities.WebDriverFactory;9import com.paypal.selion.platform.grid.Grid;10import com.paypal.selion.platform.grid.browsercapabilities.DefaultCapabilitiesBuilder;11import com.paypal.selion.platform.grid.browsercapabilities.DesiredCapabilitiesBuilder;12import com.paypal.selion.platform.grid.browsercapabilities.DesiredCapabilitiesBuilder.BrowserType;13import com.paypal.selion.platform.grid.browsercapabilities.DesiredCapabilitiesBuilder.PlatformType;14import com.paypal.selion.platform.grid.browsercapabilities.FirefoxCapabilitiesBuilder;15import com.paypal.selion.platform.grid.browsercapabilities.InternetExplorerCapabilitiesBuilder;16import com.paypal.selion.platform.grid.browsercapabilities.SafariCapabilitiesBuilder;17import com.paypal.selion.platform.grid.browsercapabilities.SafariCapabilitiesBuilder.SafariOptions;18import com.paypal.selion.platform.utilities.WebDriverWaitUtils;19public class SelionTest {20public void testSelion() {21DesiredCapabilitiesBuilder builder = new FirefoxCapabilitiesBuilder();22builder.setPlatform(PlatformType.MAC);23builder.setBrowserVersion("47.0");24builder.setCapability("marionette", true);25builder.setCapability("enableVNC", true);26builder.setCapability("enableVideo", false);27builder.setCapability("recordVideo", false);28builder.setCapability("videoName", "SelionTest.mp4");29builder.setCapability("recordScreenshots", false);30builder.setCapability("screenshotName", "SelionTest.png");31builder.setCapability("recordLogs", false);32builder.setCapability("logName", "SelionTest.log");33builder.setCapability("recordNetwork", false);34builder.setCapability("networkName", "SelionTest.har");35builder.setCapability("recordPerformance", false);36builder.setCapability("performanceName", "SelionTest.json");37builder.setCapability("recordTimeline", false);38builder.setCapability("timelineName", "SelionTest.json");39builder.setCapability("recordConsole", false);40builder.setCapability("consoleName", "SelionTest.log");41builder.setCapability("recordCommandLog", false);42builder.setCapability("commandLogName", "SelionTest.log");43builder.setCapability("recordSnapshot", false);

Full Screen

Full Screen

WebDriverFactory

Using AI Code Generation

copy

Full Screen

1import com.paypal.selion.internal.platform.grid.browsercapabilities.WebDriverFactory;2import org.openqa.selenium.WebDriver;3public class 3 {4public static void main(String[] args) {5WebDriver driver = WebDriverFactory.getWebDriver();6}7}8import com.paypal.selion.internal.platform.grid.browsercapabilities.WebDriverFactory;9import org.openqa.selenium.WebDriver;10public class 4 {11public static void main(String[] args) {12WebDriver driver = WebDriverFactory.getWebDriver("firefox");13}14}15import com.paypal.selion.internal.platform.grid.browsercapabilities.WebDriverFactory;16import org.openqa.selenium.WebDriver;17public class 5 {18public static void main(String[] args) {19WebDriver driver = WebDriverFactory.getWebDriver("chrome");20}21}22import com.paypal.selion.internal.platform.grid.browsercapabilities.WebDriverFactory;23import org.openqa.selenium.WebDriver;24public class 6 {25public static void main(String[] args) {26WebDriver driver = WebDriverFactory.getWebDriver("safari");27}28}29import com.paypal.selion.internal.platform.grid.browsercapabilities.WebDriverFactory;30import org.openqa.selenium.WebDriver;

Full Screen

Full Screen

WebDriverFactory

Using AI Code Generation

copy

Full Screen

1import com.paypal.selion.platform.grid.browsercapabilities.WebDriverFactory;2import org.openqa.selenium.WebDriver;3public class 3 {4 public static void main(String[] args) {5 WebDriver driver = WebDriverFactory.getWebDriver();6 System.out.println("Page title is: " + driver.getTitle());7 driver.quit();8 }9}10import com.paypal.selion.platform.grid.browsercapabilities.WebDriverFactory;11import org.openqa.selenium.WebDriver;12public class 4 {13 public static void main(String[] args) {14 WebDriver driver = WebDriverFactory.getWebDriver();15 System.out.println("Page title is: " + driver.getTitle());16 driver.quit();17 }18}19import com.paypal.selion.platform.grid.browsercapabilities.WebDriverFactory;20import org.openqa.selenium.WebDriver;21public class 5 {22 public static void main(String[] args) {23 WebDriver driver = WebDriverFactory.getWebDriver();24 System.out.println("Page title is: " + driver.getTitle());25 driver.quit();26 }27}28import com.paypal.selion.platform.grid.browsercapabilities.WebDriverFactory;29import org.openqa.selenium.WebDriver;30public class 6 {31 public static void main(String[] args) {32 WebDriver driver = WebDriverFactory.getWebDriver();33 System.out.println("Page title is: " + driver.getTitle());34 driver.quit();35 }36}37import com.paypal.selion.platform.grid.browsercapabilities.WebDriverFactory;38import org.openqa.selenium.WebDriver;39public class 7 {40 public static void main(String[] args) {41 WebDriver driver = WebDriverFactory.getWebDriver();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeLion automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in WebDriverFactory

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful