无法点击按钮(测试)
Unable to click a button (testing)
我的项目是使用 appium(android),selenium (java) 对 voot 应用程序进行自动化测试
我正在使用 appium desktop inspector 定位元素的 id/xpath 并将其复制到 eclipse 中。
主页上有一个没有 id 或 xpath 的“GOT IT”按钮,我该怎么办
package tests;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
import io.appium.java_client.MobileElement;
import io.appium.java_client.TouchAction;
import io.appium.java_client.touch.offset.PointOption;
public class test extends BaseClass{
@Test
public void test1(){
driver.manage().timeouts().implicitlyWait(1000, TimeUnit.SECONDS);
MobileElement el1 = (MobileElement) driver.findElementById("com.tv.v18.viola:id/btn_login_mobile");
el1.click();
System.out.println("Completed test1");
MobileElement el2 = (MobileElement) driver.findElementById("com.tv.v18.viola:id/hint_text");
System.out.println("Completed test2");
driver.hideKeyboard();
MobileElement el3=(MobileElement) driver.findElementById("com.tv.v18.viola:id/btn_login");
el3.click();
MobileElement el4=(MobileElement) driver.findElementById("com.tv.v18.viola:id/password");
System.out.println("completed test2");
driver.hideKeyboard();
}
@Test
public void test2() {
MobileElement el5=(MobileElement) driver.findElementById("com.tv.v18.viola:id/btn_login");
el5.click();
System.out.println("Completed test3");
}
@Test
public void test3() {
MobileElement el6=(MobileElement) driver.findElementById("com.tv.v18.viola:id/btn_home_page");
el6.click();
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.SECONDS);
TouchAction action0=new TouchAction(driver); //not working
action0.tap(PointOption.point(612,1329)).perform();//not working
}
screenshot
driver.findElementByName("明白了").click();
或
利用按钮的位置来制作它。()
我的项目是使用 appium(android),selenium (java) 对 voot 应用程序进行自动化测试 我正在使用 appium desktop inspector 定位元素的 id/xpath 并将其复制到 eclipse 中。 主页上有一个没有 id 或 xpath 的“GOT IT”按钮,我该怎么办
package tests;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;
import io.appium.java_client.MobileElement;
import io.appium.java_client.TouchAction;
import io.appium.java_client.touch.offset.PointOption;
public class test extends BaseClass{
@Test
public void test1(){
driver.manage().timeouts().implicitlyWait(1000, TimeUnit.SECONDS);
MobileElement el1 = (MobileElement) driver.findElementById("com.tv.v18.viola:id/btn_login_mobile");
el1.click();
System.out.println("Completed test1");
MobileElement el2 = (MobileElement) driver.findElementById("com.tv.v18.viola:id/hint_text");
System.out.println("Completed test2");
driver.hideKeyboard();
MobileElement el3=(MobileElement) driver.findElementById("com.tv.v18.viola:id/btn_login");
el3.click();
MobileElement el4=(MobileElement) driver.findElementById("com.tv.v18.viola:id/password");
System.out.println("completed test2");
driver.hideKeyboard();
}
@Test
public void test2() {
MobileElement el5=(MobileElement) driver.findElementById("com.tv.v18.viola:id/btn_login");
el5.click();
System.out.println("Completed test3");
}
@Test
public void test3() {
MobileElement el6=(MobileElement) driver.findElementById("com.tv.v18.viola:id/btn_home_page");
el6.click();
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.SECONDS);
TouchAction action0=new TouchAction(driver); //not working
action0.tap(PointOption.point(612,1329)).perform();//not working
}
screenshot
driver.findElementByName("明白了").click();
或
利用按钮的位置来制作它。(