简体   繁体   中英

Nightwatch - using execute to fill in table data cells

So I have a dynamically generated table that I am trying to use nightwatch to fill in some data with, the table is 12 x 7 and I only need to fill the middle row from top to bottom. Logically speaking I have been able to target most elements through an id or even a class selector where possible, but this table is a bit tricky.

The table cannot have an id's added to it, and is not in the semantic html as it's generated with knockout depending on certain values that are selected in the form above that I have already handled.

The page is essentially a popup modal, that blocks the rest of the ui. My thought process has been 1. Wait for element visible (this works, and I successfully see the element I am waiting for) 2. I use browser.execute to get a list of the td nodes.

const elements : NodeListOf<Element> = document.querySelectorAll('td')
const arr = [].slice.call(elements) //hacky sorry!
arr.filter // do that here

basically my issue is that using browser.execute has been hard to debug as I use the debugger in Visual Studio, I can't really step through this callback for some reason, and the querySelectorAl seems to return to me the td on the blocked ui that I am not trying to target, not on the ui I want.

Is there any advice on this being a god awful approach or perhaps a far simpler approach?

I basically ended up using execute to get a nodeList, hacked it into an array, filtered it out based on some things i wanted to use nad hacked it away. was annoying but its semi solved for now

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM