Created
April 29, 2021 08:01
-
-
Save Jaimin180296/554c973a0224a49bc6477e642f61504d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package BrowserStack; | |
import io.appium.java_client.ios.IOSDriver; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
import org.openqa.selenium.support.ui.ExpectedConditions; | |
import org.openqa.selenium.support.ui.WebDriverWait; | |
import org.testng.annotations.AfterTest; | |
import org.testng.annotations.BeforeClass; | |
import org.testng.annotations.Test; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import java.util.concurrent.TimeUnit; | |
public class iOSTab { | |
public IOSDriver driver; | |
public WebDriverWait wait; | |
public static String AUTOMATE_USERNAME = "username"; | |
public static String AUTOMATE_ACCESS_KEY = "accesskey"; | |
public static final String URL = "https://" + AUTOMATE_USERNAME + ":" + AUTOMATE_ACCESS_KEY + "@hub-cloud.browserstack.com/wd/hub"; | |
@BeforeClass | |
public void setup() throws MalformedURLException { | |
DesiredCapabilities caps = new DesiredCapabilities(); | |
caps.setCapability("os_version", "14"); | |
caps.setCapability("device", "iPhone 12"); | |
caps.setCapability("real_mobile", "true"); | |
caps.setCapability("browserstack.appium_version", "1.20.2"); | |
caps.setCapability("browserstack.local", "false"); | |
caps.setCapability("safariAllowPopups", "true"); | |
caps.setCapability("autoAcceptAlerts","true"); | |
driver = new IOSDriver(new URL(URL), caps); | |
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS) ; | |
} | |
@Test | |
public void display() throws InterruptedException { | |
wait = new WebDriverWait(driver, 30); | |
driver.get("https://euwa-dev.azurewebsites.net/?customerKey=14004&configId=efad4ae4-2552-4c34-94f8-fb34bc7af604"); | |
driver.findElement(By.xpath("//button[@aria-label='Start Chat']")).click(); | |
String code = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//span[@class='code']"))).getText(); | |
System.out.println(code); | |
driver.findElement(By.xpath("//input[@type='number']")).sendKeys(code); | |
driver.findElement(By.xpath("//button[@type='submit']")).click(); | |
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@aria-label='Close chat']"))).click(); | |
Thread.sleep(10000); | |
} | |
@AfterTest | |
public void destroy() { | |
driver.quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment