Я новичок в области автоматизации и пытаюсь щелкнуть раскрывающийся список в моем приложении в браузере Safari, но сценарий завершается ошибкой. Пожалуйста, помогите.
Ошибка:
An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DHRODCLPC0316', ip: '2409:4042:2098:9614:d857:22cd:8ec8:8ceb%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '13.0.2'
Driver info: org.openqa.selenium.safari.SafariDriver
Capabilities {applicationCacheEnabled: true, browserName: safari, cleanSession: true, cssSelectorsEnabled: true, databaseEnabled: true, handlesAlerts: true, javascriptEnabled: true, locationContextEnabled: false, nativeEvents: true, platform: MAC, platformName: MAC, rotatable: false, version: 13605.3.8, webStorageEnabled: true}
Session ID: C7B2C752-80D4-4453-B0C7-C35151B11F3C
Конфигурация:
- Safari Версия 13
- Macbook Pro machine
Поток кода
- Открыть URL https://shop-lbs.mediatis.de
- Вход с учетными данными
- Нажмите на быстрый заказ
- Введите несколько кодов, чтобы добавить в корзину
- Проверить цены и оформить заказ
- Теперь выберите адрес доставки из выпадающего списка
СКРИПТ:
package lbs.leica;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.safari.SafariDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class Testcase_240_UAT_SAFARI extends ExtentReport_UAT
{
WebDriver driver;
public static String cardNumber = "4111-1111-1111-1111";
public static String Expiry = "01/29";
@BeforeTest
public void initialization()
{
test = extent.createTest("Order tests in UAT plethora of different order tests to verify tax, shipping, customer pricing, list pricing");
driver = new SafariDriver();
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.navigate().to("https://shop-lbs.mediatis.de");
System.out.println(driver.getTitle());
reportLog(driver.getTitle());
}
@Test
public void VerifyPrices() throws IOException, InterruptedException
{
driver.findElement(By.xpath("//*[@id='login-menu_login_title']")).click();
Thread.sleep(2000);
driver.findElement(By.xpath("(//*[@id='ShopLoginForm_Login'])[2]")).clear();
driver.findElement(By.xpath("(//*[@id='ShopLoginForm_Login'])[2]")).sendKeys("fjsim@buffalo.edu");
Thread.sleep(2000);
driver.findElement(By.xpath("(//*[@id='ShopLoginForm_Password'])[2]")).sendKeys("!InterShop00!");
reportLog("Entered username and password");
// Click on login in button
driver.findElement(By.xpath("(//*[@class='account-sign-in btn btn-primary'])[2]")).click();
Thread.sleep(5000);
reportLog("Clicked on Login ");
driver.findElement(By.xpath("//*[@class='view-account']")).click();
Thread.sleep(5000);
// Click on Quick Order
driver.findElement(By.xpath("//*[@class='quickorder-li hidden-xs']")).click();
Thread.sleep(5000);
reportLog("Clicked on Quick Order ");
// Click on Copy and paste
driver.findElement(By.xpath("(//*[text()='Copy and paste'])[1]")).click();
Thread.sleep(4000);
reportLog("Clicked on Copy and paste ");
//Enter Codes in text box
String[] voucherCodes = {"DS9800 1", "PA0515 2", "AR0222 3", "PA0027 4", "PA0571 5", "PA0813 6", "3801800 1", "3803650 1", "3800680 1", "3801815 1", "3800675 1", "3800080 1", "3800050CL 1", "3800161 1"};
WebElement input = driver.findElement(By.id("addToCartCopyAndPaste_textArea"));
for (String voucher : voucherCodes)
{
input.sendKeys(voucher+"\n");
}
reportLog("Entered Codes ");
//Click on Add to cart
driver.findElement(By.id("addToCartCopyAndPaste")).click();
Thread.sleep(9000);
reportLog("Clicked on Add to cart ");
//Verify and Print price
List<WebElement> VerifyPrice = driver.findElements(By.xpath("//*[@class=' col-xs-4 col-sm-offset-1 col-sm-2 list-item column-price single-price']"));
for(WebElement price:VerifyPrice)
{
System.out.println(price.getText());
reportLog(price.getText());
}
System.out.println();
//Verify and Print Product
List<WebElement> VerifyProduct = driver.findElements(By.xpath("//*[@class='product-title']"));
for(WebElement product:VerifyProduct)
{
System.out.println(product.getText());
reportLog(product.getText());
}
System.out.println();
Thread.sleep(4000);
//Click Checkout on shopping cart page
driver.findElement(By.xpath("//*[@class='btn btn-block btn-primary']")).click();
Thread.sleep(4000);
reportLog("Clicked Checkout on shopping cart page ");
//Select shipping address
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("window.scrollTo(0, 200)");
Thread.sleep(5000);
WebDriverWait wait = new WebDriverWait(driver, 60);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("(//*[@class='btn dropdown-toggle btn-default'])[2]")));
System.out.println("Address dropdown visible");
WebElement e1 = driver.findElement(By.xpath("(//*[@class='btn dropdown-toggle btn-default'])[2]"));
e1.click();
Thread.sleep(5000);
System.out.println("Address dropdown Clicked");
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("(//*[@class='dropdown-menu inner'])[2]/li[1]")));
System.out.println(" dropdown visible");
driver.findElement(By.xpath("(//*[@class='dropdown-menu inner'])[2]/li[1]")).click();
Thread.sleep(2000);
System.out.println(" dropdown clicked");
reportLog("Selected first address ");