我们希望在我的角度2应用程序的客户端自动填写表单。 为此我们使用selenium-webdriver但我们面临以下错误。
Failed to compile.
./~/selenium-webdriver/net/portprober.js
Module not found: Error: Can't resolve 'child_process' in 'D:\AngularJS\Template\CoreUI-Free-Bootstrap-Admin-Template-master\Angular4_CLI_Full_Project\node_modules\selenium-webdriver\net'
@ ./~/selenium-webdriver/net/portprober.js 20:11-35
@ ./~/selenium-webdriver/chrome.js
@ ./~/selenium-webdriver/index.js
@ ./src/app/icons/font-awesome.component.ts
@ ./src/app/icons/icons.module.ts
@ ./src async
@ ./~/@angular/core/@angular/core.es5.js
@ ./src/main.ts
@ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
我的示例代码使用typescript
import { Component } from '@angular/core';
import { Builder, By, until } from 'selenium-webdriver';
@Component({
templateUrl: 'font-awesome.component.html'
})
export class FontAwesomeComponent {
constructor() {
var driver = new Builder()
.forBrowser('chrome')
.build();
driver.get('http://www.google.com/ncr');
driver.findElement(By.name('q')).sendKeys('webdriver');
driver.findElement(By.name('btnG')).click();
driver.wait(until.titleIs('webdriver - Google Search'), 1000);
console.log('Done!');
driver.quit();
}
}
我可以使用命令运行:node myfile.js