在前面输入图像描述,
下面是我的代码,当应用程序运行时启动,但它无法选择按钮,给出如下错误:
> info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"Element was not found."},"sessionId":"633dd3fe-7233-eb66-8903-c63b69246cf0"}
> info: <-- POST /wd/hub/session/633dd3fe-7233-eb66-8903-c63b69246cf0/element 500 30181.879 ms - 201
Test Started
FAILED: test
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 30.19 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:59:20'
System info: host: 'NCA1026471', ip: '192.168.56.1', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_66'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities [{app=C:\Appium\selendroid-test-app-0.17.0.apk, appPackage=io.selendroid.testapp, rotatable=true, networkConnectionEnabled=true, warnings={}, handlesAlerts=true, deviceName=Lokesh Gangaiah, version=0.17.0, platform=ANDROID, appActivity=io.selendroid.testapp.HomeScreenActivity, desired= {app=C:\Appium\selendroid-test-app-0.17.0.apk, appPackage=io.selendroid.testapp, appActivity=io.selendroid.testapp.HomeScreenActivity, platformVersion=5.0, browserName=, platformName=Android, deviceName=Lokesh Gangaiah, device=Android}, acceptSslCerts=true, platformVersion=21, automationName=selendroid, browserName=selendroid, takesScreenshot=true, javascriptEnabled=true, platformName=android, device=Android}]
Session ID: 633dd3fe-7233-eb66-8903-c63b69246cf0
*** Element info: {Using=id, value=io.selendroid.testapp:id/buttonStartWebview}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
import java.io.File;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.mobile.*;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class testP1 {
public static RemoteWebDriver driver;
//public static AndroidDriver<MobileElement> driver;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
File appDir = new File ("C:\\Appium\\");
//File app = new File (appDir,"CarsGuide com au_v1.0.8.1_apkpure.com.apk");
File app = new File (appDir,"selendroid-test-app-0.17.0.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName", "");
//capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "Lokesh Gangaiah");
capabilities.setCapability("platformVersion", "5.0");
capabilities.setCapability("device", "Android");
capabilities.setCapability("app",app.getAbsolutePath());
capabilities.setCapability("appPackage", "io.selendroid.testapp");
capabilities.setCapability("appActivity", "io.selendroid.testapp.HomeScreenActivity");
//capabilities.setCapability("appPackage", "au.com.carsguide");
//capabilities.setCapability("appActivity", "au.com.carsguide.activity.HomeActivity");
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void test() throws InterruptedException {
System.out.println("Test Started");
WebElement ButtonElement = driver.findElementById("io.selendroid.testapp:id/buttonStartWebview");
ButtonElement.click();
Thread.sleep(3000L);
System.out.println("Test has been completed");
//System.out.println("Hello2");
// driver.findElementByName("Search Cars for Sale").click();
//By.id("au.com.carsguide:id/search_btn").findElement(driver).click();
Thread.sleep(1000L);
}
@AfterClass
public void tearDown()
{
driver.quit();
}
}
从eclipse控制台添加wait:log后出现新错误
Test Started
FAILED: test
org.openqa.selenium.TimeoutException: Timed out after 20 seconds waiting for visibility of element located by By.id: io.selendroid.testapp:id/buttonStartWebview
生成信息:版本:“2.48.2”,修订版:“41bccdd”,时间:“2015-10-09 19:59:20”系统信息:主机:“NCA1026471”,IP:“192.168.56.1”,OS.Name:“Windows 7”,OS.arch:“AMD64”,OS.Version:“6.1”,java.Version:“1.8.0_66”驱动程序信息:org.openqa.selenium.remote.RemoteWebDriver Capilities[{app=C:\appium\selendroid-test-app-0.17.0.apk,0A6104-0D06-F75A-876C-531A23388B7C
FAILED CONFIGURATION: @BeforeClass setUpBeforeClass
java.lang.Error: Unresolved compilation problems:
The return types are incompatible for the inherited methods FindsByAccessibilityId<WebElement>.findElementsByAccessibilityId(String), AppiumDriver<RequiredElementType>.findElementsByAccessibilityId(String)
The return types are incompatible for the inherited methods FindsByCssSelector.findElementsByCssSelector(String), AppiumDriver<RequiredElementType>.findElementsByCssSelector(String)
在单击之前添加一些等待命令:
@Test
public void test() throws InterruptedException {
System.out.println("Test Started");
//wait for the button to show up before clicking
waitForElementPresent();
WebElement ButtonElement = driver.findElementByName("buttonStartWebviewCD");
ButtonElement.click();
}
public void waitForElementPresent() {
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("buttonStartWebviewCD")));
}
我正在尝试通过xpath,css,ID...但什么都管用。 我总是得到错误:没有这样的元素:无法定位元素 我添加了一个明确的等待,但它仍然不起作用。 你能帮帮我吗? 单选按钮
问题内容: 当我单击他的图像时,我想选择单选按钮,但是它不起作用。这是我尝试过的: 我的两个属性都具有相同的 data =“” 属性:对于图像和输入,单击图像时,是否有任何方法可以检查输入(该收音机)? 谢谢 更新: 我发现一些代码有效,但是仅在图像上单击了三下,因此当单击最后一个脚本时,脚本停止了,无法再次选择第一个或第二个,我不知道为什么…我认为必须取消选中所有单选按钮,然后选中选中的一个按钮
我正在尝试用Selenium Web驱动程序点击一个按钮。 (我觉得是用棱角写的??) URL为https://www.truelocal.com.au/search/accountants/canberra 这是页面底部的绿色按钮,上面有“加载更多结果” 元素页源是...
我在中放了一个按钮,将其移动到下一个活动,但当我单击该按钮时,它什么也不做,包括不将其移动到下一个活动。 我尝试过将按钮放在外部,但是当出现时,按钮已经消失了。我尝试修改关于的所有代码,但没有成功。 这是展示它的活动 这是按钮的第一个.xml布局 这是按钮的第二个.xml布局 这是我的Rsolvermatch活动,它已经影响onclicklistener的元素,但导致错误
我正在尝试通过文本选择列表中的条目。li条目也有ID,但我想用文本代替。 我有以下html片段: Leier kommunal bolig Leier bolig 选项一:我试着这样做: 我试过“值”和其他选项。但我总是得到“指定了一个无效或非法的选择器”。 但显然有问题,因为它没有导航到页面上的列表条目,并且该选项没有被选中。 另外,如果我使用.sendKeys(keys.enter)而不是.c