Open Edge in InPrivate mode using Selenium - selenium

I am using Selenium 3.4 to launch Edge using the Microsoft WebDriver which is now maintained by Microsoft.
Is there any way I can launch the Browser in InPrivate mode using Selenium?
I have searched for answers but couldn't find any.
The closest I got was How to start Edge browser in Incognito mode using selenium remote webdriver?
The solution mentioned there doesn't work. It just shows the same tab as would be shown in InPrivate, but the window isn't a private one. As such, the information is stored and the session is not private.

Add capabilities...
Try the code below.
DesiredCapabilities capabilities = DesiredCapabilities.edge();
capabilities.setCapability("ms:inPrivate", true);
return new EdgeDriver(capabilities);

I made the capabilities work in Python like this:
from selenium.webdriver import Edge
from selenium.webdriver import DesiredCapabilities
capabilities = DesiredCapabilities.EDGE
capabilities['ms:inPrivate'] = True
driver = Edge(capabilities=capabilities)

Use the below code, employing java.awt.Robot to simulate the key combination CTRL+SHIFT+P to open a new browser window in InPrivate mode:
System.setProperty("webdriver.edge.driver","D:\\Workspace\\StackOverlow\\src\\lib\\MicrosoftWebDriver.exe"); //put actual location
WebDriver driver = new EdgeDriver();
driver.navigate().to("https://www.google.com");
driver.manage().window().maximize();
Robot robot;
try {
// This is the actual code that opens the InPrivate window
robot = new Robot();
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(KeyEvent.VK_P);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.keyRelease(KeyEvent.VK_P);
Thread.sleep(3000);
} catch (AWTException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String parentWindowHandler = driver.getWindowHandle();
String subWindowHandler = null;
Set<String> handles = driver.getWindowHandles();
Iterator<String> iterator = handles.iterator();
while (iterator.hasNext()){
subWindowHandler = iterator.next();
driver.switchTo().window(subWindowHandler);
System.out.println(subWindowHandler);
}
driver.get("https://stackoverflow.com/");
//driver.switchTo().window(parentWindowHandler); // Uncomment this line if you want to use normal browser back
}
Note that we are using robot class and so if the system locks it may not work.

Related

selenium.UnsupportedCommandException: the requested resource could not be found, or a request

getting exception
FAILED CONFIGURATION: #AfterClass tearDown
"org.openqa.selenium.UnsupportedCommandException: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource"
enter code here
public class BaseClass {
//read config file and initiate variables
ReadConfig readConfig = new ReadConfig();
public String username = readConfig.getUserName();
//public String password = "asas";
public String password = readConfig.getPassword();
public static AppiumDriver driver;
public static org.apache.logging.log4j.Logger logger;
#BeforeClass
public void setUp ()
{
try {
logger = LogManager.getLogger(BaseClass.class);
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability(MobileCapabilityType.DEVICE_NAME, "bd178829");
dc.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
dc.setCapability(MobileCapabilityType.APP, "D:\\automation\\CRMNextMobileAutomation\\src\\test\\resources\\apps\\CRMNextNative 6.29.0-release_screenshot_enabled.apk");
dc.setCapability("automationName","UiAutomator2");
dc.setCapability("appPackage", "com.crmnextmobile.crmnextofflineplay");
dc.setCapability("appActivity", "com.crmnextmobile.crmnextofflineplay.qr.QrScannerActivity");
dc.setCapability("enforceAppInsall", true);
URL url = new URL("http://127.0.0.1:4723/wd/hub");
driver = new AppiumDriver(url,dc);
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
System.out.println("CRMNext automation start..");
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
//Clicking on Allow option on open permission pop up
//driver.findElement(By.id("com.android.permissioncontroller:id/permission_allow_button")).click();
if(!driver.findElements(By.id ("com.android.permissioncontroller:id/permission_allow_button")).isEmpty()){
//THEN CLICK ON THE SUBMIT BUTTON
System.out.println("permission_allow_button is found on page");
driver.findElement(By.id("com.android.permissioncontroller:id/permission_allow_button")).click();
}else{
//DO SOMETHING ELSE AS SUBMIT BUTTON IS NOT THERE
System.out.println("permission_allow_button not found on page");
}
//Clicking on Allow button of run in background pop up
//driver.findElement(By.id("android:id/button1")).click();
if(!driver.findElements(By.id ("android:id/button1")).isEmpty()){
//THEN CLICK ON THE SUBMIT BUTTON
System.out.println("button1 is found on page");
driver.findElement(By.id("android:id/button1")).click();
}else{
//DO SOMETHING ELSE AS SUBMIT BUTTON IS NOT THERE
System.out.println("button1 not found on page");
}
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
Thread.sleep(5000);
System.out.println("CRMNext automation Before Skip..");
//Clicking on Skip button
driver.findElement(By.id("com.crmnextmobile.crmnextofflineplay:id/skip")).click();
System.out.println("CRMNext automation after Skip..");
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
Thread.sleep(10000);
driver.findElement(By.id("com.crmnextmobile.crmnextofflineplay:id/relative_layout_continue")).click();
Thread.sleep(2000);
} catch (Exception exp) {
// TODO: handle exception
System.out.println("Cause is :"+exp.getCause());
System.out.println("Message is :"+exp.getMessage());
exp.printStackTrace();
}
}
#Test
public void sample() {
System.out.println("Sample run");
}
#AfterClass
public void tearDown()
{
driver.close();
driver.quit();
}
//org.openqa.selenium.UnsupportedCommandException: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
all tests are failing due to this.
driver.close()
The driver.close() command is used to close the current browser window having focus. In case there is only one browser open then calling driver.close() quits the whole browser session.
Usability
Use driver.close() when dealing with multiple browser tabs or windows e.g. when clicking on a link that opens another tab. In this case after performing required action in the new tab, to close the tab, call the driver.close() method.
driver.quit()
The driver.quit() is used to quit the whole browser session along with all the associated browser windows, tabs and pop-ups.
Usability
Use driver.quit() when no longer want to interact with the driver object along with any associated window, tab or pop-up. Generally, it is the last statements of the automation scripts. Call driver.quit() in the #AfterClass method to close it at the end of the whole suite.
Use following code in #AfterClass
#AfterClass
public void tearDown()
{
if (driver != null)
driver.Quit();
}

driver.close() will hang for forever

driver.close() is not working on Jenkins and the whole test will hang for forever. I am using Selenium Grid with Java and using Chrome Driver.
I don't want to user driver.quit(). I have to use driver.close(). I have two tabs open and i have to close one.
public static void closeBrowser()
{
try
{
WebDriver testDriver = BrowserFactory.getInstance().getDriver();
if (testDriver != null)
{
testDriver.close();
}
wait.wait(2);
Log.info("Closing the browser");
}
catch (Exception e)
{
Log.info("Cannot close browser");
}
}
This used to work and started to happen recently.
Try this following:
driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL + "w");
This code will close the currently opened tab.
Better solution i found to close window is:
((JavascriptExecutor) BrowserFactory.getInstance().getDriver()).executeScript( "window.close()" );

Drag and drop functionality not working in selenium chromedriver

I am working on a drag and drop functionality using selenium chromedriver. But unfortunately unable to achieve it. I am using following piece of code,
public void dragAndDropElement() {
try {
WebElement imgToDrag = driver.findElement(By
.className("imageclassname"));
WebElement dropHere = driver.findElement(By.cssSelector("panelcssname"));
Actions action = new Actions(driver);
Actions actions = null, movetoElement = null;
actions = action.clickAndHold(imgToDrag);
Thread.sleep(3000);
movetoElement = actions.moveToElement(dropHere);
movetoElement.perform();
movetoElement.release();
Thread.sleep(6000);
} catch (Exception e) {
logger.log(Level.SEVERE, "Exception occured in DragAndDropClass :: dragAndDropElement()", e);
}
}
After running this code, nothing is happening I mean neither it is throwing any exception nor it is performing drag and drop functionality. What mistake I am doing here, can anybody help me to get out of this problem.

My scrip works fine in java class but same script fails when I use testng. It just opens the browser and fails my script

Please Find the below code: I have performed the following steps, but didn't worked.
Please Help:
public class ForSe_TestCases
public WebDriver driver;
#BeforeTest
public void setup ()
{
System.setProperty("webdriver.chrome.driver", "path");
WebDriver driver =new ChromeDriver();
driver.manage().deleteAllCookies();
}
#Test(priority = 0)
public void Validlogin_IO () throws InterruptedException {
driver.navigate().to("http://**URL**");
driver.findElement(By.xpath("//*[#id='email_address']")).sendKeys("tengku.forse#gmail.com");
driver.findElement(By.xpath("//*[#id='password']")).sendKeys("Pass12345");
driver.findElement(By.xpath("//*[#id='login-form']/div[4]/button")).click();
System.out.println("Login button pressed");
}
What can be the issue with TestNG ?
Try any/all of the following
Remove and Add TestNG jar again to ur project build path
UNinstall and reinstall the TestNG plugin
Clean the Eclipse project amd rerun.
If nothing works try this :
public static void main(String[] args) {
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
testng.setTestClasses(new Class[] { YOURCLASSNAME.class });
testng.addListener(tla);
testng.run();
}
In place of YOURCLASSNAME give the classname that contains the #Test annotations. This is like running your testing without the plugin from main method.
Sanchit, I think it fails because you are not waiting for the element to appear on the page and the webDriver (which is faster than its shadow!) thinks the first element you are trying to locate isn't there (id='email_address).
Try reading here for implicit or explicit way to wait or use this code of mine below instead (if the element is present then the method returns true):
public boolean waitForElement(String elementXpath, int timeOut) {
try{
WebDriverWait wait = new WebDriverWait(driver, timeOut);
boolean elementPresent=wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(elementXpath)).isDisplayed());
System.out.printf("%nElement is present [T/F]..? ")+elementPresent;
}
catch(TimeoutException e1){e1.printStackTrace();elementPresent=false;}
return elementPresent;
}
Update after OP's comments
To see if my method works, try replacing your first find element line:
driver.findElement(By.xpath("//*[#id='email_address']")).sendKeys("tengku.forse#gmail.com"); //this is official email
with this code below instead (then your script won't break from then ownwards, if it does use this waiting method again for the 'breaking' element). I think your script is breaking straight away because you locate the element and sendKeys very fast without waiting for it to appear first!
waitForElement ("//*[#id='email_address']", 10);
if(elementPresent==true){
driver.findElement(By.xpath("//*[#id='email_address']")).sendKeys("tengku.forse#gmail.com");
}
else{
System.out.println("FATAL! Couldn't locate email address field!");
}
Hope you can crack it this time round!
Update to Chrome driver 2.28, Google Chrome to 57.x and Selenium to 3.x.x You also have to set the path of the Chrome driver before you open the browser.
package demo;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class TestAnyURL_TestNG
{
WebDriver driver;
#BeforeTest
public void setup ()
{
System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
options.addArguments("start-maximized");
options.addArguments("--js-flags=--expose-gc");
options.addArguments("--enable-precise-memory-info");
options.addArguments("--disable-popup-blocking");
options.addArguments("--disable-default-apps");
options.addArguments("test-type=browser");
options.addArguments("disable-infobars");
driver = new ChromeDriver(options);
driver.manage().deleteAllCookies();
}
#Test(priority = 0)
public void Validlogin_IO () throws InterruptedException
{
driver.navigate().to("http://google.com"); //ForSe test environment URL
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(By.xpath("//*[#id='email_address']")).sendKeys("tengku.forse#gmail.com"); //this is official email
driver.findElement(By.xpath("//*[#id='password']")).sendKeys("Pass12345"); //this is password
driver.findElement(By.xpath("//*[#id='login-form']/div[4]/button")).click(); //click on submit button to login
System.out.println("Login button pressed"); } //This code is to add new case
#Test (priority = 1)
public void AddCase() throws InterruptedException
{
WebElement element = driver.findElement(By.partialLinkText("Add Case")); //To find 'Add Case' button on dashboard
Actions action = new Actions (driver); action.moveToElement(element); //Move mouse and hover to 'Add Case' button
action.click().build().perform(); //Click on 'Add Case' button
driver.findElement(By.id("name")).sendKeys("Perak Murder Case -53311");//Provide Case Name
driver.findElement(By.id("fileupload")).sendKeys("C:\\Users\\sanchit.IGENEDC\\Desktop\\iCSIImages\\FisheyeImages\\IMG_1187.JPG"+"\n"+"C:\\Users\\sanchit.IGENEDC\\Desktop\\iCSIImages\\FisheyeImages\\IMG_1188.JPG"+"\n"+"C:\\Users\\sanchit.IGENEDC\\Desktop\\iCSIImages\\FisheyeImages\\IMG_1189.JPG"+"\n"+"C:\\Users\\sanchit.IGENEDC\\Desktop\\iCSIImages\\Fisheye Images\\IMG_1190.JPG"); //Upload files
driver.findElement(By.id("fileupload1")).sendKeys("C:\\Users\\sanchit.IGENEDC\\Desktop\\iCSIImages\\EvidenceImages\\_DSC0970.JPG"+"\n"+"C:\\Users\\sanchit.IGENEDC\\Desktop\\iCSI>Images\\EvidenceImages\\_DSC0971.JPG"+"\n"+"C:\\Users\\sanchit.IGENEDC\\Desktop\\iCSIImages\\Evidence Images\\_DSC0972.JPG");
Thread.sleep(6000); //wait for files to load
driver.findElement(By.id("btnSubmit")).click();//click on submit button
}
}
Check this code. This code successfully opens the google.co.in
Execute this file "Run As TestNG Test"
Let me know if this helps you.

LeanFT and Selenium Compatibility?

I would like to know if Selenium and LeanFT can play nicely together. I don't know if anyone has tried to do this yet, but I think if it can work, LeanFT can provide some supplementary benefits to the selenium framework.
As I understand it currently, the limitations of Selenium are:
Selenium MUST open the initial browser to recognize it
Selenium MUST open all popups to recognize them.
Selenium WebDriver may become stale while waiting for non-Selenium procedures.
I have attempted the object flow UML for both HP's suggested model and my own idea of how this might work.
The Control flow would be something like:
#Before -> globalSetup (LeanFT init)
#BeforeClass -> testSetup (LeanFT init)
#BeforeClass -> getSeleniumDriver (Selenium)
#Test -> some selenium procedures
/**** To prevent Selenium from dying. ****/
#Test -> new Thread -> run leanFTsnippet1()
#Test -> resume selenium final steps..
#After -> reporting, closing Webdriver
Here is some of my current code from an example Test Class.
#BeforeClass
public static void beforeLFTClass() throws Exception {
globalSetup(CoreFunctionality.class);
}
#AfterClass
public static void afterLFTClass() throws Exception {
globalTearDown();
}
#Test
public void runLeanFtThread() {
// put selenium code here
// ...
// begin leanft part of test
Thread leanftThread = new Thread( new Runnable() {
#Override
public void run() {
try {
test();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
leanftThread.start();
try {
leanftThread.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void test() throws Exception {
//Starting Browser
Browser browser = BrowserFactory.attach(new BrowserDescription.Builder().title(driver.getTitle()).build());
Assert.assertEquals(browser.getTitle(), driver.getTitle());
}
Anyways, its a pretty interesting problem. Would really love to see what you guys think.
Thanks!
They indeed play nicely together. I have been using them in my scripts and I like to utilize the powers of each tool. What I have done is create a LeanFT test template and add the Selenium libraries to it.
Here is a sample code:
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using HP.LFT.SDK;
using HP.LFT.SDK.Web;
using Search_Regression_Test;
using TestAutomationReporting;
using UnifiedFramework;
using System.Configuration;
using System.Diagnostics;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
using Selenium = OpenQA.Selenium;
namespace Search_Regression_Test
{
[TestClass]
public class LeanFtTest : UnitTestClassBase<LeanFtTest>
{
static IBrowser browser;
static IWebDriver chromeDriver;
[ClassInitialize]
public static void ClassInitialize(TestContext context)
{
GlobalSetup(context);
ChromeOptions CO = new ChromeOptions();
CO.AddExtension(#"C:\Program Files (x86)\HP\LeanFT\Installations\Chrome\Agent.crx");
chromeDriver = new ChromeDriver(CO);
chromeDriver.Manage().Window.Maximize();
browser = BrowserFactory.Attach(new BrowserDescription
{
Type = BrowserType.Chrome
});
.... and so on.
The new Version of LeanFT (14) even brings some explicit Selenium-integration: You can select Selenium as your automation SDK in the project creation wizard, there is a Selenium-specific Object Identification Center, and some additional locators and utilities. Full story here: LeanFT for Selenium.
I'm not entirely sure why this question doesn't have an accepted answer yet, but I'm going to take a stab at answering this with a sample that highlights once more that LeanFT and Selenium are playing nicely together
It's written in Java. Probably it can be optimized a bit, but it should clearly show how you can achieve simultaneous interaction with the same browser.
(The Java Project was created from LeanFT templates. UnitTestClassBase class comes from there. It basically initializes LeanFT and the reporter behind the scenes. To get around it if you don't want to use it you'd have to call SDK.init(), Reporter.init(), Reporter.generateReport() and SDK.cleanup() as needed - check the docs for details)
The AUT used is advantage shopping: http://advantageonlineshopping.com/
package com.demo;
import static org.junit.Assert.*;
import java.io.File;
import java.util.Calendar;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.Keys;
import org.openqa.selenium.chrome.*;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.hpe.leanft.selenium.By;
import com.hp.lft.report.Reporter;
import com.hp.lft.report.Status;
import com.hp.lft.sdk.web.*;
import com.hp.lft.verifications.Verify;
public class SeleniumTest extends UnitTestClassBase {
private ChromeDriver chromeDriver;
private Browser browser;
public SeleniumTest() {
System.setProperty("webdriver.chrome.driver",this.getClass().getResource("/chromedriver.exe").getPath());
}
#BeforeClass
public static void setUpBeforeClass() throws Exception {
instance = new SeleniumTest();
globalSetup(SeleniumTest.class);
}
#AfterClass
public static void tearDownAfterClass() throws Exception {
globalTearDown();
}
#Before
public void setUp() throws Exception {
// SELENIUM: Construct and launch the browser with LeanFT agent
ChromeOptions options = new ChromeOptions();
File paths = new File("C:\\Program Files (x86)\\HP\\LeanFT\\Installations\\Chrome\\Agent.crx");
options.addExtensions(paths);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
chromeDriver = new ChromeDriver(options);
}
#After
public void tearDown() throws Exception {
// LEANFT: close the browser opened by selenium
browser.close();
}
#Test
public void test() throws Exception {
// SELENIUM: Go to the Advantage shopping website and maximize it
chromeDriver.get("http://156.152.164.67:8080/#/");
chromeDriver.manage().window().maximize();
// LEANFT: Attach to the browser
browser = BrowserFactory.attach(new BrowserDescription.Builder()
.type(BrowserType.CHROME).openTitle(" Advantage Shopping")
.build());
// LEANFT: Click on tablets button
browser.describe(WebElement.class, new WebElementDescription.Builder()
.className("categoryCell").tagName("DIV").innerText("TABLETS Shop Now ").build()).click();
// SELENIUM: Expand the display section after it was seen
(new WebDriverWait(chromeDriver, 10))
.until(new ExpectedCondition<org.openqa.selenium.WebElement>(){
#Override
public org.openqa.selenium.WebElement apply(org.openqa.selenium.WebDriver d) {
return d.findElement(By.cssSelector("h4#accordionAttrib0"));
}}).click();
// LEANFT: select the preferred display size, click the preferred tablet and add the tablet to the cart
browser.describe(CheckBox.class, new CheckBoxDescription.Builder()
.type("checkbox").role("").accessibilityName("").tagName("INPUT").name("").index(1).build()).set(true);
browser.describe(Image.class, new ImageDescription.Builder()
.alt("").type(com.hp.lft.sdk.web.ImageType.NORMAL).tagName("IMG").index(1).build()).click();
browser.describe(Button.class, new ButtonDescription.Builder()
.buttonType("submit").tagName("BUTTON").name("ADD TO CART").build()).click();
// SELENIUM: go to cart
chromeDriver.get("http://156.152.164.67:8080/#/shoppingCart");
// LEANFT: checkout
browser.describe(Button.class, new ButtonDescription.Builder()
.buttonType("submit").tagName("BUTTON").name("CHECKOUT ($1,009.00)").build()).click();
// SELENIUM: Register as a new user after the button was seen
(new WebDriverWait(chromeDriver, 10))
.until(new ExpectedCondition<org.openqa.selenium.WebElement>(){
#Override
public org.openqa.selenium.WebElement apply(org.openqa.selenium.WebDriver d) {
return d.findElement(By.xpath("//DIV[#id=\"newClient\"]/DIV[1]/SEC-FORM[1]/SEC-SENDER[1]/BUTTON[#role=\"button\"][1]"));
}}).click();
// LEANFT: fill in the user name and email
String username = "U" + Calendar.getInstance().getTimeInMillis(); // unique name each time
browser.describe(EditField.class, new EditFieldDescription.Builder()
.type("text").tagName("INPUT").name("userName").build()).setValue(username);
browser.describe(EditField.class, new EditFieldDescription.Builder()
.type("text").tagName("INPUT").name("userEmail").build()).setValue("myuser_email#emailsite.org");
// SELENIUM: Set password and confirm password
chromeDriver.findElementByXPath("//SEC-VIEW/DIV[normalize-space()=\"*Password\"]/INPUT[1]").sendKeys("Password1");
chromeDriver.findElementByXPath("//SEC-VIEW/DIV[normalize-space()=\"*Confirm password\"]/INPUT[1]").sendKeys("Password1");
// LEANFT: check the 'I agree' checkbox and register, then click on next shipping details.
browser.describe(CheckBox.class, new CheckBoxDescription.Builder()
.type("checkbox").tagName("INPUT").name("registrationAgreement").build()).set(true);
browser.describe(Button.class, new ButtonDescription.Builder()
.buttonType("button").tagName("BUTTON").name("REGISTER").build()).click();
browser.describe(Button.class, new ButtonDescription.Builder()
.buttonType("submit").tagName("BUTTON").name("NEXT").build()).click();
// SELENIUM: confirm the user name and pass
chromeDriver.findElementByXPath("//DIV[#id=\"paymentMethod\"]/DIV/DIV/SEC-FORM/SEC-VIEW/DIV[normalize-space()=\"*SafePay username\"]/INPUT[1]").sendKeys(username);
chromeDriver.findElementByXPath("//DIV[#id=\"paymentMethod\"]/DIV/DIV/SEC-FORM/SEC-VIEW/DIV[normalize-space()=\"*SafePay password\"]/INPUT[1]").sendKeys("Password1");
// LEANFT: click "Pay now" and confirm payment was done
browser.describe(Button.class, new ButtonDescription.Builder()
.buttonType("button").role("button").accessibilityName("").tagName("BUTTON").name("PAY NOW").index(0).build()).click();
Verify.isTrue(
browser.describe(WebElement.class, new WebElementDescription.Builder()
.tagName("SPAN").innerText("Thank you for buying with Advantage").build())
.exists());
}
}