我是初学者。无法在test.js中调用go_home_page
// test.js
var homePage = require('./home_page');
var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;
var driver = new webdriver.Builder()
.forBrowser('firefox')
.build();
home = new homePage(driver);
home.go_home_page();
// home_page.js
class homePage{
constructor(driver){
this.driver = driver;
}
go_home_page(){
this.driver.get("https://www.google.com/");
}
}
TypeError: homePage is not a constructor
如何调用go_home_page()
使用导入和类?
答案 0 :(得分:0)
您需要使用def animate(self):
self.draw_one_frame()
self.stop_id = self.after(100, self.animate)
def cancel(self):
self.after_cancel(self.stop_id)
导出要在module.exports
中使用的模块。所以你可以做这样的事情
test.js
然后在module.exports={
homePage1 : homePage
}
文件