我正在OpenLayers
使用Selenium WebDriver
(Java版本)测试API .
我想测试一个使用OpenLayers
.Control.ModifyFeature 的功能.我想点击绘制的特征(SVG),然后拖动并检查它们是否存在,可见或隐藏.
我画了一个多边形,我选择了它.见下图:
这些SVG元素的HTML在这里:
<svg id="OpenLayers_Layer_Vector_161_svgRoot" width="1235" height="495" viewBox="0 0 1235 495" style="display: block;">
<g id="OpenLayers_Layer_Vector_161_root" transform="" style="visibility: visible;">
<g id="OpenLayers_Layer_Vector_161_vroot">
<path id="OpenLayers_Geometry_Polygon_200" d=" M 393.0000000000964,213.9999999999891 486.0000000003338,275.9999999997126 384.00000000036925,284.9999999994434 393.0000000000964,213.9999999999891 z" fill-rule="evenodd" fill="blue" fill-opacity="0.4" stroke="blue" stroke-opacity="1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="none" pointer-events="visiblePainted" cursor="pointer" />
<circle id="OpenLayers_Geometry_Point_619" cx="439.50000000021464" cy="244.99999999985084" r="6" fill="#009900" fill-opacity="0.5" stroke="#ee9900" stroke-opacity="1" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="none" pointer-events="visiblePainted" cursor="inherit" />
<circle id="OpenLayers_Geometry_Point_621" cx="435.00000000035106" cy="280.49999999958163" r="6" fill="#009900" fill-opacity="0.5" stroke="#ee9900" stroke-opacity="1" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="none" pointer-events="visiblePainted" …
Run Code Online (Sandbox Code Playgroud) 我正在记录JavaScript API.我正在关注谷歌风格指南,但我没有发现标签的顺序.
我通常会记录一个这样的变量:
/**
* @description Radius of the circle
* @private
* @memberOf Circle
* @type {Number}
* @default
*/
Circle.prototype._radius = 1;
Run Code Online (Sandbox Code Playgroud)
如您所见,我使用自己的订单编写标签,这是我认为最直观的订单.
以下是按字母顺序排列标签的相同文档:
/**
* @default
* @description Radius of the circle
* @memberOf Circle
* @private
* @type {Number}
*/
Circle.prototype._radius = 1;
Run Code Online (Sandbox Code Playgroud)
尽管如此,我有一个明确定义的顺序(按字母顺序),我发现这有点令人困惑,因为它会混淆评论的自然顺序.这就是为什么我正在寻找一种方法来编写具有特定官方订单的标签.
甚至还有这些标签的正式订单?
谢谢
我想知道如何从其他文件中获取json模式.
假设我有两个文件,放在同一目录中:
文件1:person.json
{
"id":"#person",
"name": {"type":"string"},
"age": {"type":"number"},
"address": {
"type":"object",
"properties": {
"number": {"type":"number"},
"street": {"type":"string"},
"city": {"type":"string"}
}
}
}
Run Code Online (Sandbox Code Playgroud)
文件2:company.json
{
"id":"#company",
"name": {"type":"string"},
"employees": {
"type":"array",
"items" {"$ref":"person.json"}
}
}
Run Code Online (Sandbox Code Playgroud)
正如您可能观察到的那样,"员工"应该是一群"人".问题是我不知道如何引用"人"模式,因为它在不同的文件中.
我知道这可能是一个简单的问题,并且可能已经有了相关的答案,但我已经研究了很多,我不明白这是怎么做的.
编辑1
我使用Tiny Validator 4(tv4)进行模式验证.我也在使用QUnit测试模式是否正常运行.
下面,我将向您展示一个测试,其中地址编号是布尔值,它应该是类型编号.架构验证,何时不应该验证.
asyncTest("invalid type for adress number", function() {
expect(1);
var jsonObject = {
name: 'Computers Inc',
employees: [
{
name: 'John',
age: 29,
address: {
number: 9,
street: 'Oak Street',
city: 'London'
}
},
{
name: 'Mike', …
Run Code Online (Sandbox Code Playgroud) 我正在写一些类型检查功能.我想要:
在编写isInteger时,我注意到isInteger(1.0)返回true.我希望这会返回false.
我的功能是这样的:
function isInteger(value) {
return typeof value === 'number' && value % 1 === 0;
}
Run Code Online (Sandbox Code Playgroud)
我还注意到它返回true为1.0,因为参数'value'立即转换为1(我不想要).
我这样做了:
function isInteger(value) {
console.log(value) // It prints 1 if value is 1.0
return typeof value === 'number' && value % 1 === 0;
}
Run Code Online (Sandbox Code Playgroud)
当然,我考虑可能需要使用regEx的情况:
var regEx = /^-?[0-9]+$/;
regEx.test(value)
Run Code Online (Sandbox Code Playgroud)
但是,首先我需要函数来实际测试值1.0而不是1.
我怎么能这样做才能在函数参数中维护1.0?
谢谢
javascript ×2
file ×1
integer ×1
java ×1
jsdoc ×1
jsonschema ×1
reference ×1
regex ×1
selenium ×1
svg ×1
tags ×1
typechecking ×1
xpath ×1