Home > Blockchain >  How to unhide an element from javascript execute() method?
How to unhide an element from javascript execute() method?

Time:11-16

I'm doing automation using WDIO and want to upload a file but the input element is disabled. The style element of the input selector has :

enter image description here

When I change it to this, element is visible

enter image description here

I wish to change this through my javascript code, this is what I've tried so far:

const inputFilePath = "#kyc-image-file-input";
await this.driver.execute(
   (elem) => elem.style.display = 'block',
   await this.driver.$(inputFilePath),
 );
 await WaitUtil.pause(this.driver, 5000);
 await (await this.digioPage.getPanAndAadhaarUploadFileInputEle()).setValue(remoteFilePath);
 await WaitUtil.pause(this.driver, 5000);

Javascript throws the below error when I do this: enter image description here

Please let me know the correct way of changing the display property.

Thanks in advance :)

CodePudding user response:

You need to change style:

(elem) => elem.style.display = 'block'

CodePudding user response:

Try this, selecting the element you want to change:

const inputFilePath = "#kyc-image-file-input";

await this.driver.execute(
   (elem) => 
       document.querySelector(elem).style.display = 'block',
       await this.driver.$(inputFilePath),
 );
  • Related