Issue with Object Reference not set to instance of an object comparing get text to data table

First of all I’m not sure my sequences is set up correct but when I run it I get this error message For Each Row: Object reference not set to an instance of an object.

Scenario: I am trying to compare data in a data table and column “PID” to data from the get text which I output to a variable of “cap_Text” The I am trying to compare both with the condition of row.item(“PID”).ToString = line.Item(“cap_Text”).ToString I should be getting back that they match but I can’t get that far due to the error.

This error usually means you have a variable that was not initialized or was never populated with data. Make sure dt_veritity and cap_Text are both datatables and both have at least one row in them.

I tested the first one dt_veritity that displayed data in a message box, the problem I’m having is getting the get text data to display. I see the data in the select editor but when I try to display it in a message box it does not work so this is where I think the issue is. I tried to output the variable as a data table and then display it in a message box but no go?

Get Text doesn’t give you a datatable, it gives you a string. Data scraping will give you a datatable.

Why do you have WaitForReady set to NONE? That could be your issue, the Get Text is executing before the page has actually loaded. Set it to interactive.

That isn’t it, I just can’t get this to do what I think it should do. Get Text the compare that text to the data in excel and if a match …if not then…the erro is clearly coming from the get text and then it gets to the for each and I get that message. I am totally missing something here :frowning:

Again, you have the Get Text set to WaitForReady.NONE - why?

Set it to interactive or complete and then test again.

1 Like

You have aaname=‘30253040’ in your selector. Because of this, it will only ever select the cell that has that exact value. You need to edit your selector to remove aaname and add other properties so that it identifies the correct cell to read, but doesn’t use the value as part of what to select.

Thank you for the help. I took the string from get text and built a data table, I got past that issue and I understand your question about the selector I will convert that to a wildcard once I get this to work. So now the message I get is If: Column ‘PID’ does not belong to table TableName. I know there is a column in the datatable called PIN

I was able to identify the data coming out of the get text field but I’m at a loss as to what to do next to that I can run an if statement against the PIN in excel and the get text number?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.