[SOLVED] How to tell if a DOM object exists on a webpage
Posted: 15 Aug 2015, 09:17
I’ve been working with DOM to be able to automatically populate the fields on a web page. I used iWB2 Learner to get the names of the fields and it is going well, and I have been able to access and populate/write all the input fields, such as: (using wb := IEGet("Calendar - Bookeo") from Jethreow)
However, I am trying to add a bit of error checking into the code and “check” and see if the user is on the correct page, before allowing the script to proceed further. Using the “handle” wb := IEGet("Calendar - Bookeo") and checking to see if it is valid won’t work because there are several screens/modes on the webpage that still have that as a title, so I really need to check and see if the input box exists.
However, I can’t seem to get the syntax correct. I’ve tried using the index number (although I’d rather check the actual “name” since I’m worried that the index number might change).
How could I check the existence of an input box on a page (hopefully using the input box name)?
Code: Select all
wb.Document.All.cardType.Value := "VISADEBIT"
wb.Document.All.cardNumber.Value := "1234123412341234"
wb.Document.All.cardHolderName.Value := "John Smith"
wb.Document.All.expiryMonth.Value := "12"
wb.Document.All.expiryYear.Value := "2021"
wb.Document.All.cvv.Value := "999"
However, I can’t seem to get the syntax correct. I’ve tried using the index number (although I’d rather check the actual “name” since I’m worried that the index number might change).
Code: Select all
if wb.Document.All.cardNumber.index = 120
{
msgbox, found object
}