我正在使用 Gremlins.JS 和 Cypress 来模糊应用程序。为了创建自定义 gremlin,我正在尝试使用此代码块
function customGremlin() {
return function attack() {
document.getElementById("search_query_top").value = "Johnny Bravo"
};
}
并像这样使用它:
before(() => {
return cy.visit('http://automationpractice.com/index.php').then(() =>
cy.window().then((pageWindow) => {
horde = createHorde({
window: pageWindow,
species : [customGremlin]
});
})
);
});
但是我收到以下错误:
Cannot set property 'value' of null
为了document.getElementById("search_query_top").value = "Johnny Bravo"
任何帮助表示赞赏。