我一直试图注入webdriver这些步骤.我已经使用了这个说明并且效果很好.
我们的想法是将WebDriver作为服务注入步骤类.在初始步骤中,您需要添加以下依赖项.
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-spring</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
依赖注入涉及三个主要类.在这里,我们逐一介绍它们.
BaseUtil
BaseUtil是具有WebDriverof Selenium属性的类.这堂课很简单:
public class BaseUtil {
private WebDriver driver;
public WebDriver getDriver() {return driver;}
public void setDriver(WebDriver driver) { this.driver = driver;}
}
Run Code Online (Sandbox Code Playgroud)
钩
Hook类包含@Before, @After.方法testInitialier()负责加载webDriver 文件并创建实例,而方法testTearDown()负责关闭浏览器.
public class Hook extends BaseUtil{
BaseUtil base;
@Before
public void testInitializer(){
File file = new
File(IgniteTaskApplication.class.getClassLoader().getResource("driver/chromedriver.exe").getFile());
String driverPath=file.getAbsolutePath();
System.out.println("Webdriver is in path: "+driverPath);
System.setProperty("webdriver.chrome.driver",driverPath);
base.setDriver(new ChromeDriver());
}
public Hook(BaseUtil base) {
this.base = base;
}
@After …Run Code Online (Sandbox Code Playgroud) 我正在做一个项目。在那里我应该找到一年的总周数。我尝试使用以下代码,但得到错误答案:2020 年有 53 周,但此代码给出了 52 周。
我在这段代码中哪里出错了?
package com.hib.mapping;
import java.time.LocalDate;
import java.time.temporal.WeekFields;
import java.util.Calendar;
import java.util.GregorianCalendar;
import org.joda.time.DateTime;
public class TestWeek {
public static void main(String args[]) {
System.out.println(getWeeks());
}
public static int getWeeks() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 2020);
cal.set(Calendar.MONTH, Calendar.JANUARY);
cal.set(Calendar.DAY_OF_MONTH, 1);
GregorianCalendar gregorianCalendar = new GregorianCalendar();
int weekDay = cal.get(Calendar.DAY_OF_WEEK) - 1;
if (gregorianCalendar.isLeapYear(2020)) {
if (weekDay == Calendar.THURSDAY || weekDay == Calendar.WEDNESDAY)
return 53;
else
return 52;
} else {
if (weekDay == Calendar.THURSDAY) …Run Code Online (Sandbox Code Playgroud) 我在页面中有5个api调用。一些api需要20秒才能做出响应。有些需要30秒才能做出回应。有些需要10秒钟,因此,当第一个api做出响应时,第一个api将加载指示器设置为false。然后加载指示器消失。但是其他API仍在工作,我想显示加载指示器,直到五个API调用响应为止。你能给我一些想法做这个任务吗?
码:
component.ts
loading = true;
ngInit() {
this.api1();
this.api2();
this.api3();
this.api4();
this.api5();
}
api1(){
this.loading=true;
this.apiService.api1.subscribe(response => {
loading = false;
}, error=>{
});
}
api2(){
this.loading=true;
this.apiService.api2.subscribe(response => {
loading = false;
}, error=>{
});
}
api3(){
this.loading=true;
this.apiService.api3.subscribe(response => {
loading = false;
}, error=>{
});
}
api4() {
this.loading=true;
this.apiService.api4.subscribe(response => {
loading = false;
}, error=>{
});
}
api5() {
this.loading=true;
this.apiService.api5.subscribe(response => {
loading = false;
}, error=>{
});
}
Run Code Online (Sandbox Code Playgroud)
ApiService.service.ts:
api1(): any { …Run Code Online (Sandbox Code Playgroud) @Column(name = "password", nullable = false)
@JSonIgnore
private String password;
Run Code Online (Sandbox Code Playgroud)
我在我的模型类中给出了上述字段,但它不适用于 POST 方法。
错误:“密码”列中的空值违反了非空约束
当 JWT 令牌过期时,Web 应用程序应显示一个alert或 模式弹出窗口,然后应重定向到登录页面。目前我正在使用烤面包机消息。
我的组件中有很多 api 调用。我收到许多烤面包机消息“令牌已过期”。我应该只显示一条消息并重定向到登录页面。告诉我你的好主意。我在互联网上有一些文章。但我无法清楚地了解这些事情。
import {
HttpEvent,
HttpInterceptor,
HttpHandler,
HttpRequest,
HttpResponse,
HttpErrorResponse
} from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { retry, catchError } from 'rxjs/operators';
import { Router } from '@angular/router';
import { ToastrManager } from 'ng6-toastr-notifications';
import { Injectable } from '@angular/core';
import { JwtDecoderService } from './jwt-decoder.service';
@Injectable()
export class HttpErrorInterceptor implements HttpInterceptor {
constructor(public router: Router,
public toastr: ToastrManager,
private jwtDecoder: JwtDecoderService, ) {
}
intercept(request: HttpRequest<any>, …Run Code Online (Sandbox Code Playgroud) 我是 apache 和 php 的新手。我把Apache服务器安装在C盘,C:\Apache24. 然后我使用此命令在 CMD 中安装了服务
httpd -k install。然后我去Windows服务。我可以启动和停止Apache2.4,它工作正常。我想运行 php 项目。现在我在C:\php7.
PHP版本:
PHP 7.3.0RC3 (cli) (built: Oct 10 2018 01:23:45) ( NTS MSVC15 (Visual C++ 2017) x64 ),
Copyright (c) 1997-2018, The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
Run Code Online (Sandbox Code Playgroud)
然后我打开 Apachehttpd.conf文件 (C:/Apache24/conf/httpd.conf)。
PHPIniDir "C:/php7"
AddHandler application/x-httpd-php .php
LoadModule php7_module "C:/php7/php7apache2_4.dll" [this is line no 550]
Run Code Online (Sandbox Code Playgroud)
我在 httpd.conf 中添加了上面的行。然后使用此命令httpd -k start或其他命令启动 Apache,我可以在Windows 服务中启动它。
因此,我收到了这个错误。为什么我不知道。
C:\Apache24\bin>httpd …Run Code Online (Sandbox Code Playgroud)