我对 Angular 非常陌生,我正在尝试创建一个比默认输入字段更长的表单。这是我当前的代码:
person.component.html
<form class="new-person-form">
<mat-card>
<mat-form-field>
<input matInput placeholder="Name">
</mat-form-field>
<mat-form-field>
<input matInput placeholder="Birthday">
</mat-form-field>
<mat-checkbox>Active</mat-checkbox>
</mat-card>
</form>
Run Code Online (Sandbox Code Playgroud)
person.component.css
.mat-form-field {
padding: 10px;
}
.mat-checkbox {
padding: 10px;
}
Run Code Online (Sandbox Code Playgroud)
person.component.html
<form class="new-person-form">
<mat-card fxLayout="row">
<mat-form-field>
<input matInput placeholder="Name" fxFlex="50">
</mat-form-field>
<mat-form-field>
<input matInput placeholder="Birthday" fxFlex="25">
</mat-form-field>
<mat-checkbox fxFlex="25">Active</mat-checkbox>
</mat-card>
</form>
Run Code Online (Sandbox Code Playgroud)
person.component.css
.mat-form-field {
padding: 10px;
}
.mat-checkbox {
padding: 10px;
}
Run Code Online (Sandbox Code Playgroud)
这是结果:
| |
| Name___________ Birthday_______ [] Active |
| |
Run Code Online (Sandbox Code Playgroud)
我试图加长Name
到页面的 50% 左右,所以是这样的:
| …
Run Code Online (Sandbox Code Playgroud) 我正在使用Maven运行几个selenium自动化测试.当我在Eclipse中调试时,我通常只需右键单击testing.xml和Run As> TestNG Suite.但是在Jenkins中运行需要运行mvn test
.但是当我运行它时,我得到了几个错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project ecom: Compilation failure: Compilation failure:
[ERROR] /Users/kroe761/Documents/workspace/ecom/src/main/java/com/company/automation/ecom/HelperMethods.java:[15,43] package com.company.automation.ecom.pages does not exist
[ERROR] /Users/kroe761/Documents/workspace/ecom/src/main/java/com/company/automation/ecom/HelperMethods.java:[16,43] package com.company.automation.ecom.pages does not exist
[ERROR] /Users/kroe761/Documents/workspace/ecom/src/main/java/com/company/automation/ecom/HelperMethods.java:[110,13] cannot find symbol
[ERROR] symbol: class Header
[ERROR] location: class com.company.automation.ecom.HelperMethods
[ERROR] /Users/kroe761/Documents/workspace/ecom/src/main/java/com/company/automation/ecom/HelperMethods.java:[110,62] cannot find symbol
[ERROR] symbol: class Header
[ERROR] location: class com.company.automation.ecom.HelperMethods
[ERROR] /Users/kroe761/Documents/workspace/ecom/src/main/java/com/company/automation/ecom/HelperMethods.java:[113,9] cannot find symbol
[ERROR] symbol: class SignIn
[ERROR] location: class com.company.automation.ecom.HelperMethods
[ERROR] /Users/kroe761/Documents/workspace/ecom/src/main/java/com/company/automation/ecom/HelperMethods.java:[113,58] cannot find symbol
[ERROR] …
Run Code Online (Sandbox Code Playgroud) 我的selenium测试需要一个xpath表达式来获取这个元素:
<td class="label"> Order Date </td>
Run Code Online (Sandbox Code Playgroud)
但不是这个:
<td class="label"> Order Dates </td>
Run Code Online (Sandbox Code Playgroud)
我试过这两个:
"//*[text() = 'Order Date']"
"//*[text()[contains(.,'Order Date')]]"
Run Code Online (Sandbox Code Playgroud)
但是精确匹配表达式不会考虑空格,而contains表达式也会以元素为目标s
.
我按照这些说明创建了一个在Lambda中执行的基本Web scraper.我有编写selenium代码的经验,但没有使用Node JS.我让项目在Lambda中运行,但是当我尝试在本地编辑项目以执行我想要的selenium代码时,它不起作用.exports.handler
我跑的时候没有任何东西被执行node index.js
.我如何在本地执行此项目?谢谢!
我正在尝试将响应对象从我的 angular 项目中的 HTTP Post 请求转换为Person
我定义的类。我在 HTTP 服务中定义了一个通用的 post 方法,并在我的个人服务中调用它,将通用替换为Person
. 所以,我想,既然我已经做了 HTTPresponse
应该是一个Person
,但它不是 - 它只是一个Object
. 我需要它是 aPerson
因为我的 Person 类上有一些我需要访问的自定义逻辑。我可以在我的个人服务中编写一个辅助方法,但我觉得这应该可行 - 特别是因为 VS Code 智能感知说response
我的组件中的 是Person
当我将鼠标悬停在它上面时。
这是我的代码:
http.service.ts
@Injectable()
export class HttpService {
baseUrl = 'https://baseurl.com';
constructor(private http: HttpClient) { }
post<T>(endpointUrl: string, body: any): Observable<T> {
const fullUrl = this.baseUrl + endpointUrl;
return this.http
.post<T>(fullUrl, body)
.pipe(
map(response => response as T)
);
}
} …
Run Code Online (Sandbox Code Playgroud) 我正在使用RestClient和Ruby v.2.2.1尝试使用内部测试API服务器.
这基本上是代码:
url = "https://10.10.0.10/thing/i/want/to/get"
header = {
:content_type => "application/json",
:"x-auth-token" => "testingtoken"
}
response = RestClient.get url, header
Run Code Online (Sandbox Code Playgroud)
这是我收到的失败消息:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (RestClient::SSLCertificateNotVerified)
Run Code Online (Sandbox Code Playgroud)
如果我正确阅读,看起来Ruby无法接受SSL安全证书.此调用适用于Chrome应用Postman,但为了使其正常工作,我必须点击Chrome本身的网址并接受连接不安全(但仍然继续),然后它将在邮递员中工作.
有没有办法忽略证书失败并继续在Ruby中继续?
我正在尝试使用Cucumber/Java编写一些selenium自动UI测试.如果我的功能文件中只有一个测试,一切正常.但是,如果我添加第二个测试,我会收到此错误driver.get()
:
org.openqa.selenium.remote.SessionNotFoundException: Session ID is null. Using WebDriver after calling quit()?
Build info: version: '2.51.0', revision: '1af067dbcaedd7d2ab9af5151fc471d363d97193', time: '2016-02-05 11:20:57'
Run Code Online (Sandbox Code Playgroud)
基本上,我在一个包中初始化InitializeWebdriver类上的webdriver变量,然后在其他(步骤定义)类中引用它.我确实将下面列出的步骤定义作为InitializeWebdriver类的一部分,并且它工作正常(直到转移到另一个类中的不同步骤.所以我将该步骤移动到CommonSteps.java文件以查看它是否然后会失败,而且做到了.所以,现在我只是卡住了.我在想这样做的的if (driver.equals(null))
的@Before
,做不同的动作,如果已经初始化,但我不知道其他的动作会是什么.
这是我的代码:
tests.feature
Feature: Two tests
Background:
Given I navigate to "http://www.google.com"
Scenario: Test one
When something happens
Scenario: Test two
When something else happens
Run Code Online (Sandbox Code Playgroud)
InitializeWebDriver.java
public class InitializeWebDriver {
public static WebDriver driver = null;
@Before
public void beforeScenario() {
driver = new ChromeDriver();
}
@After
public void afterScenario() {
driver.quit();
} …
Run Code Online (Sandbox Code Playgroud) 我正在使用 Java 和 TestNG 框架为我的公司编写一些 selenium 自动化 UI 测试。我在一个Base
类中定义驱动程序,我想实际初始化驱动程序@BeforeTest
并在@AfterTest
方法中退出它。假设它们在不同的类中,Java 的方法是什么?我知道如何让它在同一个班级中工作,但不知道如何在不同的班级中工作。这是我的Base.java
文件:
public class Base {
public static WebDriver driver = null;
public WebDriver getDriver() {
driver = new ChromeDriver();
return driver;
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我想要一个单独的 Setup 类和一个单独的 Teardown 类。如果我要在同一个中定义所有这些@Test
,我会这样做:
@Test
public void testOne() {
Base b = new Base();
WebDriver driver = b.getDriver();
// Do test-y things here.
driver.quit();
}
Run Code Online (Sandbox Code Playgroud)
我该如何设置?尝试学习正确的方法来做到这一点,而不是一起破解某些东西。如果需要,我还可以提供更多信息。谢谢!
我正在编写一个节点 API,并希望将 Sequelize 查询的结果保存在一个变量中,作为块外的普通 JavaScript 对象findAll
。我有一些有用的东西,但没有我想要的那么好。这是我所拥有的:
router.get('/', (req, res, next) => {
models.User.findAll({
attributes: ['id', 'name'],
raw: true
}).then(function (results) {
console.log(results); // Plain JavaScript object, which is good
// Do logic on results
//Return results
res.status(200).json({
results
});
});
});
Run Code Online (Sandbox Code Playgroud)
但我真的不想将我的所有逻辑都保留在then()
块中,尤其是因为我可能想在此之前或之后进行一些其他查询。我真的想要这样的东西(如果这是一件事):
router.get('/', (req, res, next) => {
var users = models.User.findAll({
attributes: ['id', 'name'],
raw: true
}).then(function (results) {
});
});
// Do logic on results
// return results
res.status(200).json({
results
});
}); …
Run Code Online (Sandbox Code Playgroud) 使用 Entity Framework Core 将数据插入多个表(其中一个或多个新记录包含第一个表的外键)的最佳方法是什么?
鉴于这些实体:
public class ParentEntity
{
public int Id {get; set;}
public string Name {get; set;}
}
public class ChildEntity
{
public int Id {get; set;}
public int ParentId {get; set;}
public string Name {get; set;}
}
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用这种方法插入数据:
var parentEntity = new ParentEntity {Name = "Mom"};
var childEntity = new ChildEntity {Name = "Junior"};
await db.Parents.AddAsync(parentEntity);
childEntity.ParentId = parentEntity.Id;
await db.Children.AddAsync(childEntity);
await _context.SaveChangesAsync();
Run Code Online (Sandbox Code Playgroud)
但我可以看到这不会很好地扩展。我现在正在学习 EF Core,我找不到更好的方法来处理这个问题。
java ×3
angular ×2
javascript ×2
node.js ×2
selenium ×2
aws-lambda ×1
cucumber-jvm ×1
eclipse ×1
express ×1
maven ×1
observable ×1
rest-client ×1
ruby ×1
sequelize.js ×1
ssl ×1
testng ×1
xpath ×1