有没有办法配置 willPopScope 来捕获自定义弹出导航,如下所示?我有一个自定义 Raisingbutton 小部件,带有 onPressed 来导航回上一页。
但 willPopScope 不会像 AppBar 后退按钮那样捕获导航。我不确定这是否可能。请指教。谢谢!
WillPopScope(
child: Scaffold(
body: Container(
child: Center(
child: RaisedButton(
onPressed:(){
return Navigator.pop(context);
},
child: Text("Go Back),
),
),
),
),
onWillPop: () async {
// code to show a modal
}
);
Run Code Online (Sandbox Code Playgroud) 我正在尝试请求我正在开发的应用程序的位置权限。它在 Android 设备上完美运行,但在 iOS 设备上没有任何提示。目标 iOS 版本是 11,我使用的软件包是geolocator: ^5.3.1和permission_handler: ^5.0.0+hotfix.5。
这是我的代码。
这是我的实用程序函数,用于在状态不是 时请求许可granted。
Future<PermissionStatus> getDeviceLocationPermission() async {
final PermissionStatus permissionStatus =
await Permission.locationWhenInUse.status;
if (permissionStatus != PermissionStatus.granted) {
await Permission.locationWhenInUse.request();
}
return permissionStatus;
}
Run Code Online (Sandbox Code Playgroud)
这是我收集职位详细信息的实用函数。
Future<Position> getDeviceCurrentLocation(
{@required PermissionStatus permissionStatus}) async {
Position position;
Geolocator geolocator = Geolocator()..forceAndroidLocationManager;
if (permissionStatus == null) {
return null;
}
if (permissionStatus == PermissionStatus.granted) {
position = await geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.high);
}
return position;
}
Run Code Online (Sandbox Code Playgroud)
这就是我在有状态小部件内访问这些实用程序的方式。
getDeviceLocationPermission().then((permissionStatus) { …Run Code Online (Sandbox Code Playgroud) 我收到以下错误或$ mvn编译:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Sym360: Compilation failure: Compilation failure:
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
[ERROR] -> [Help 1]
Run Code Online (Sandbox Code Playgroud)
这是我的pom.xml的代码:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.app</groupId>
<artifactId>Tset</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Test</name>
<url>http://maven.apache.org</url>
<properties>
<maven.compiler.source>6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<!-https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-
java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.14.0</version> …Run Code Online (Sandbox Code Playgroud) 我试图将我的测试作为一个套件运行。套件中有三个测试,如何在每次测试后关闭浏览器?
suites:
{
one: 'one.js',
two: 'two.js',
three: 'three.js'
};
Run Code Online (Sandbox Code Playgroud)
问题是这个测试中的每一个都是用来加载一个单独的url,每个测试都检查是否加载了正确的url。但是我的测试每次都失败,因为所有的 url 都不一样。
我正在尝试使用 Maven 设置测试。我在尝试运行命令“mvn test”时收到以下错误:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/dso/Documents/Eclipse-Workspace/MavenSample/src/test/java/MavenSample/MavenSample/RestAPITest.java:[3,30] cannot find symbol
symbol: class Test
location: package org.testng.annotations
Run Code Online (Sandbox Code Playgroud)
mvn clean 和 mvncompile 对我来说都可以正常工作,没有错误。如果测试只是作为 testng 运行,那么测试本身也可以正常运行。mvn 测试完成后测试失败。下面是我的 pom.xml 文件的代码。
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MavenSample</groupId>
<artifactId>MavenSample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MavenSample</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.0.0-beta4</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured --> …Run Code Online (Sandbox Code Playgroud) 我想检查文本内容是否为one或two:
await expect(this.header).toHaveText('one').or('two')
Run Code Online (Sandbox Code Playgroud)
有没有办法使用 Playwright 使其发挥作用?
这也可以在像这样的句子中实现
await expect(this.header).toHaveText("this is "+('first').or('second')+ "sentence");
Run Code Online (Sandbox Code Playgroud) flutter ×2
maven ×2
testng ×2
alert ×1
eclipse ×1
java ×1
location ×1
navigation ×1
permissions ×1
playwright ×1
protractor ×1
selenium ×1
suite ×1
testing ×1
typescript ×1