NoMethodError for innerText

Hello,

I'm new to all of this. I have a script that behaves rather erratically.

I'm getting the following error...

  1) Error: test_capital_by_division(SampleTest): NoMethodError: undefined method `innerText' for nil:NilClass     X:/SOM/Admin/Finance/Reporting/Cognos/QA/scripts/DEV/working/CAPTEST.rb:71:i n `test_capital_by_division'

This refers to the following line in my code:

assert_equal("$977,352" , @b.element_by_xpath("//form/table/tbody/tr[3]/td/div/div/table/tbody/tr[2]/td/div/div/div/table/tbody/tr[165]/td[2]/span[1]").innerText )

The weird thing is that there are other parts in this script where the very some logic is used and it has no problems. So the results are entirely inconsistent. My first test case I have set up with 4 very similar assert_equal's passes with flying colors.

The script in its entirety is as follows. Do I need to include a require & include for innerText at the beginning of my script? I'm using Ruby 1.8.7-p334. Any suggestions?

Hello,

I'm new to all of this. I have a script that behaves rather erratically.

I'm getting the following error...

1) Error: test_capital_by_division(SampleTest): NoMethodError: undefined method `innerText' for nil:NilClass

Note the wording above carefully.

X:/SOM/Admin/Finance/Reporting/Cognos/QA/scripts/DEV/working/CAPTEST.rb:71:i n `test_capital_by_division'

This refers to the following line in my code:

assert_equal("$977,352" , @b.element_by_xpath("//form/table/tbody/tr[3]/td/div/div/table/tbody/tr[2]/td/div/div/div/table/tbody/tr[165]/td[2]/span[1]").innerText

The error is saying that you tried to call nil.innerText. That means that your call to element_by_xpath returned nil.

Colin