On Thu, Sep 30, 2010 at 5:10 PM, ISmellGas
wrote:
> Ok, thanks for your help Željko.
No problem. You will find this group friendly to new people.
> As I said, it's a long road ahead!
The road has no end. :)
Željko
--
Before posting, please read http://watir.com/support. In short: search befo
Ok, thanks for your help Željko.
As I said, it's a long road ahead!
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com
On Thu, Sep 30, 2010 at 5:03 PM, ISmellGas
wrote:
> How could I turn this into
> a method so that I do not have to type it out every time?
You should read this :)
http://ruby-doc.org/docs/ProgrammingRuby/
> I have used methods a little but I am not sure how I could pass the
> arguments?
def my
> It is scope thing. You should always use local variables, unless you really
> need to access them from other code.
That sort of brings me on to my next query. How could I turn this into
a method so that I do not have to type it out every time?
I have used methods a little but I am not sure how
On Thu, Sep 30, 2010 at 4:52 PM, ISmellGas
wrote:
> Is there a disadvantage doing it this way or is it just
> not the done thing?
It is scope thing. You should always use local variables, unless you really
need to access them from other code.
Željko
--
Before posting, please read http://watir.
> @length = @contents.length
Ahhh...yes, thats a bit neater.
>Why is everything in instance variables (they begin with @)?
I am not sure really. I find it easier to pick out variables when they
start with @. Is there a disadvantage doing it this way or is it just
not the done thing?
--
Before
On Thu, Sep 30, 2010 at 4:29 PM, ISmellGas
wrote:
> @contents = b.select_list(:name, "mydropdown").getAllContents
> @length = b.select_list(:name, "mydropdown").getAllContents.length
You could do it this way:
@length = @contents.length
> @random = Kernel.rand(@length)
> @value = @conten...@rand
Ok, I have given it a go and it seems to work. This is pretty basic so
any tips will be gratefully received!
@contents = b.select_list(:name, "mydropdown").getAllContents
@length = b.select_list(:name, "mydropdown").getAllContents.length
@random = Kernel.rand(@length)
@value = @conten...@random]