PageObject with Ruby - set text in a text field only works in the main file

前端 未结 2 1429
面向向阳花
面向向阳花 2021-01-24 12:21

I\'m automating a site that has a page with a list of options selected by a radio button. When selecting one of the radios, a text field and a select list are presented.

2条回答
  •  心在旅途
    2021-01-24 12:45

    In ruby all equals methods (methods that end with the = sign) need to have a receiver. Let me show you some code that will demonstrate why. Here is the code that sets a local variable to a value:

    domain = "blah"
    

    and here is the code that calls the domain= method:

    domain = "blah"
    

    In order for ruby to know that you are calling a method instead of setting a local variable you need to add a receiver. Simply change your method above to this and it will work:

    def configure_domain(config={})
        check_option_sub_domain
        self.domain = config[:domain]
        self.tld = config[:tld]
    end
    

提交回复
热议问题