Вопрос пользователя:
Ответ нейросети:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class MtsByTests {
private WebDriver driver;
@BeforeTest
public void setup() {
System.setProperty("webdriver.chrome.driver", "path_to_chromedriver");
driver = new ChromeDriver();
driver.get("https://www.mts.by/");
}
@Test
public void testOnlineRechargeBlock() {
WebElement onlineRechargeBlock = driver.findElement(By.xpath("//div[@class='online-recharge']"));
Assert.assertTrue(onlineRechargeBlock.isDisplayed(), "Online Recharge block is not displayed");
WebElement blockTitle = onlineRechargeBlock.findElement(By.tagName("h2"));
Assert.assertEquals(blockTitle.getText(), "Онлайн пополнение без комиссии", "Block title is incorrect");
WebElement paymentLogos = onlineRechargeBlock.findElement(By.xpath("//div[@class='payment-logos']"));
Assert.assertTrue(paymentLogos.isDisplayed(), "Payment logos are not displayed");
WebElement moreDetailsLink = onlineRechargeBlock.findElement(By.xpath("//a[text()='подробнее о сервисе']"));
moreDetailsLink.click();
Assert.assertEquals(driver.getCurrentUrl(), "https://www.mts.by/more_details", "More details link is not working");
WebElement phoneNumberInput = driver.findElement(By.id("phone_number"));
phoneNumberInput.sendKeys("297777777");
WebElement servicesDropdown = driver.findElement(By.id("services_dropdown"));
servicesDropdown.click();
WebElement servicesOption = driver.findElement(By.xpath("//option[text()='Услуги связи']"));
servicesOption.click();
WebElement continueButton = driver.findElement(By.id("continue_button"));
continueButton.click();
// Add more assertions as needed for further testing of the process after clicking Continue button
}
@AfterTest
public void tearDown() {
driver.quit();
}
}
Пожалуйста, убедитесь, что у вас установлен Selenium WebDriver и TestNG, а также укажите правильный путь к драйверу Chrome в методе setup()
. В данном примере приведены основные шаги для тестирования блока "Онлайн пополнение без комиссии" на сайте mts.by. Вам может потребоваться дополнительные проверки и ассерты в зависимости от функционала сайта.
Обратите внимание: ответы, предоставляемые искусственным интеллектом, могут не всегда быть точными. Не рассчитывайте на них в критически важных областях, таких как медицина, юриспруденция, финансы или в вопросах, связанных с безопасностью. Для важных решений всегда обращайтесь к квалифицированным специалистам. Администрация сайта не несет ответственности за контент, сгенерированный автоматически.