我正在尝试使用Selenium,WebDriver.io和Node.js(使用Mocha)测试一个简单的表单.所以我有这样的事情:
var webdriverio = require('webdriverio');
var expect = require('expect');
describe('Test form', function(){
beforeEach(function() {
browser.url('/');
});
it('should save object', function() {
expect(browser.executeScript('return window.data;')).to.be([]);
});
afterEach(function() {
if (this.currentTest.state !== "passed") {
browser.saveScreenshot();
}
});
});
Run Code Online (Sandbox Code Playgroud)
我的wdio.conf.js:
var selenium = require('selenium-standalone');
var seleniumServer;
exports.config = {
host: '127.0.0.1',
port: 4444,
specs: [
'test/*.spec.js'
],
capabilities: [{
browserName: 'chrome'
}],
baseUrl: 'http://localhost:8080',
framework: 'mocha',
mochaOpts: {
ui: 'bdd'
},
onPrepare: function() {
return new Promise((resolve, reject) => {
selenium.start((err, process) …Run Code Online (Sandbox Code Playgroud) 我正在使用 Go 和 Gorilla Mux。
这是我的 webserver.go 文件
package main
import (
"log"
"net/http"
"github.com/gorilla/mux"
)
func HomeHandler(rw http.ResponseWriter, r *http.Request) {
http.ServeFile(rw, r, "index.html")
}
func main() {
r := mux.NewRouter()
r.HandleFunc("/", HomeHandler)
http.Handle("/", r)
log.Println("Server running on :8080")
err := http.ListenAndServe(":8080", r)
if err != nil {
log.Printf("Error: %s\n", err.Error())
}
}
Run Code Online (Sandbox Code Playgroud)
在 webserver.go 文件所在的同一文件夹中还有 index.html 文件。
/ - 这是index.html
/css - 所有 CSS 文件
/images - 所有图像、资源文件
我设法使用上面的代码加载index.html 文件,但它似乎没有加载CSS 文件和图像。
在我的index.html 文件中。
<link rel="stylesheet" type="text/css" href="css/demo.css" /> …Run Code Online (Sandbox Code Playgroud)