问题
Complete JQuery newbie here, so apologies if I'm missing something blatantly obvious! :) As part of my nightwatchjs test script, I'm using JQuery to try and stop a Cookie Policy window from displaying.
The Cookie Policy window ID is displayed as either;
div[id=sp_message_container_156527]
or
div[id=sp_message_container_156525]
which of these is displayed is completely random, supplied by a 3rd party.
So I thought I'd use JQuery to try and 'hide' this element from appearing when the page is loaded (which makes my further commands in my script infinitely easier to run) using the following in my nightwatchjs test script;
const { JSDOM } = require( 'jsdom' );
const { window } = new JSDOM( '' );
const $ = require( 'jquery' )( window );
exports.command = function() {
this.pause(5000);
$('div[id*=sp_message_container]').hide();
this.pause(3000);
};
However, this does not appear to work, as the element is still being displayed.
Am I doing something obviously wrong here?
Thanks.
来源:https://stackoverflow.com/questions/62592170/cannot-hide-changing-element-using-jquery