1. Open Goolge Chorme Application
2. Navigate to google site
3. Input text "shift asia" then click on search button
4. Click on the result with "https://shiftasia.com"
Main page
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.*;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.MalformedURLException;
import java.net.URL;
public class androidTest {
static WebDriver driver;
@BeforeAll
public static void setUpClass() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "9.0.0");
capabilities.setCapability("deviceName", "emulator-5554");
capabilities.setCapability("browserName", "Chrome");
capabilities.setCapability("automationName", "UiAutomator1");
capabilities.setCapability("chromedriverExecutable", "D:\\androidTest\\drivers\\chromedriver.exe");
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@Test
public void googleTest() {
// navigate to google site
driver.navigate().to("https://www.google.com/");
//Input and Search text 'ShiftAsia'
driver.findElement(By.name("q")).sendKeys("ShiftAsia");
driver.findElement(By.xpath("//button[@class='Tg7LZd']")).click();
//Click link Shift Asia
driver.findElement(By.xpath("//a[@href=\"https://shiftasia.com/\"]")).click();
}
}