在谷歌Chrome版本38+中,有一个带有设备仿真选项的新黑色标尺.有谁知道如何禁用它?

是否可以在我使用时禁用日期我想禁用一个方案的当前日期和其他方案的未来日期.我该如何禁用日期?
我正在尝试 100% 的测试覆盖率,但我似乎无法测试这个 onUploadFile 函数中的内容。
<input type="file" formControlName="theUpload" id="upload" (change)="onUploadFile($event, i, true)">
Run Code Online (Sandbox Code Playgroud)
onUploadFile(evt: Event, index: number, isReq: boolean = false): void {
const reader = new FileReader();
const target = <HTMLInputElement>evt.target;
if (target.files && target.files.length) {
const file = target.files[0];
reader.readAsDataURL(file);
reader.onload = () => {
this.getUploadFormGroup(index, isReq).patchValue({
filename: file.name,
filetype: file.type,
value: reader.result.split(',')[1],
dateUploaded: new Date()
});
console.log(
`getUploadFormArray (${isReq ? 'required' : 'other'} forms)`,
this.getUploadFormArray(isReq)
);
};
}
}
Run Code Online (Sandbox Code Playgroud)
it('should call onUploadFile when input is …Run Code Online (Sandbox Code Playgroud) 在 Python 上的 Selenium 中,我尝试使用选择一个元素
driver = webdriver.Firefox()
driver.find_element_by_css_selector("td:contains('hello world')")
Run Code Online (Sandbox Code Playgroud)
这给了我错误:
>>>> selenium.common.exceptions.WebDriverException: Message: u'An invalid or illegal string was specified'
Run Code Online (Sandbox Code Playgroud)
我可以通过这种方式使用许多不同的 CSS 选择器来选择元素,但使用 :contains() 似乎总是会抛出错误。注意:当我尝试使用时遇到同样的错误:
driver.find_element_by_xpath("//td[contains(text(),'hello world')]")
Run Code Online (Sandbox Code Playgroud)
请指教。谢谢!
编辑:解决了!
问题解决了!非常感谢你的帮助!我犯了两个重大错误:1.)我认为 :contains() 是一个可接受的 css3 选择器(事实证明它不是当前规范的一部分,这就是为什么我无法选择这种方式)2.)xpath 选择器本来就很好,除了我使用的解析器假设 xpath 中永远不会有任何空格,因此它按空格分割参数。因此,当我传入 xpath 选择器时
//td[contains(text(),'hello world']
Run Code Online (Sandbox Code Playgroud)
解析器在“hello”之后的空格处被截断,因此 xpath 选择器看起来像
//td[contains(text(),'hello
Run Code Online (Sandbox Code Playgroud)
这显然会引发错误。所以我需要调整我的解析以正确读取我的 xpath 选择器。
再次感谢您所有快速、有用的答案!
我在尝试测试我的组件时不断收到错误。
这是my.component.spec.ts:
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { MyComponent } from './my.component';
import { LocalStorageService } from '../../services/local-storage.service';
import { DataTablesModule } from 'angular-datatables';
fdescribe('MyComponent', () => {
let component: MyComponent;
let fixture: ComponentFixture<MyComponent>;
let de: DebugElement;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [MyComponent],
imports: [DataTablesModule.forRoot()],
providers: []
}).compileComponents().then(() => {
fixture = TestBed.createComponent(MyComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
Run Code Online (Sandbox Code Playgroud)
和my.component.ts
从 '@angular/core' 导入 { Component, …
如何将OPTIONAL参数传递给angularJS模态?这是我的代码:
控制器A(TRIGGER):
$modal.open({
templateUrl: 'UploadPartial.html',
controller: 'photos.uploadCtrl',
resolve: {
preselectedAlbum: function preselectedAlbum() {
return angular.copy($scope.selectedAlbum);
}
}
});
Run Code Online (Sandbox Code Playgroud)
控制器B(模态):
app.controller('photos.uploadCtrl', [
'$scope',
'$modalInstance',
'$injector',
function uploadCtrl($scope, $modalInstance, $injector) {
if ($injector.has('preselectedAlbum')) {
console.log('happy'); // I want this to work, but $injector doesn't find it
} else {
console.log('sad'); // Always gets here instead :(
}
}
]);
Run Code Online (Sandbox Code Playgroud)
注意:当我把它preselectedAlbum作为一个依赖项时它可以工作,但是每当我没有明确地传入它时我就会得到错误.我希望它是可选的.
我的代码包含if这样的代码块
服务:
import { isDevMode } from '@angular/core';
export class MyService {
constructor() {}
methodToTest(): {
if (!isDevMode()) {
doSomething();
} else {
doSomethingDifferentInDevMode();
}
}
}
Run Code Online (Sandbox Code Playgroud)
my-service.spec.ts(仅相关行):
it('should run doSomething() when isDevMode() returns false', () => {
// what should i do here to mock a false value return for isDevMode() ?
expect(doSomething).toHaveBeenCalled();
});
Run Code Online (Sandbox Code Playgroud)
我如何监视isDevMode()此单个Angular单元测试使其返回false,以便我可以测试doSomething()被调用的?
angular ×3
jasmine ×3
unit-testing ×2
angularjs ×1
datatables ×1
date ×1
datepicker ×1
html5 ×1
javascript ×1
jquery ×1
python ×1
rulers ×1
selenium ×1
typescript ×1
xpath ×1