Selecting first repository item [SOVLED...ish]

Ask general questions here.
blackout
Posts: 14
Joined: Thu Mar 14, 2013 10:07 am

Selecting first repository item [SOVLED...ish]

Post by blackout » Tue Apr 30, 2013 4:07 pm

Hi guys,

I've asked a question on here before and got a prompt and helpful response that led me to resolving my issue in a more roundabout fashion, so I thought I'd give another question bash (^_^)

Issue:

OK, I have my repository broken down into lots of folders as there are constant changes all over the place and it needs to be managed effectively.

In one of the folders is a lot of jpeg pictures that appear on a specific page of the website. However, my code currently looks for a specific item within that repository folder and PerformClicks it. This has worked in the short term:

Code: Select all

repo.TestWeb.Teams.Profile1.PerformClick();
Very simple.

Is there any way to change this code so that it does something like the following:

Code: Select all

repo.TestWeb.Teams.<FIRST FOLDER ITEM>.PerformClick();
I don't want to specify what the first item in the folder is, and I want to treat it as 'unknown' so that whatever the first item in the repository folder happens to be, is the picture that I click on.


I've searched the forums and the user guides but can't see anything specific to this scenario, or even slightly helpful in regards.

Anyone have any ideas that will make me hate myself for not having the sense to see how to do this?


Cheers.
Last edited by blackout on Wed May 01, 2013 12:36 pm, edited 1 time in total.

gannias
Posts: 7
Joined: Tue Apr 30, 2013 5:50 pm

Re: Selecting first repository item

Post by gannias » Tue Apr 30, 2013 8:32 pm

Have you tried ?

var item = repo.<YourFolder><YourFolder>.Self.Children[0];

blackout
Posts: 14
Joined: Thu Mar 14, 2013 10:07 am

Re: Selecting first repository item

Post by blackout » Wed May 01, 2013 11:15 am

Thanks Gannias,

I hadn't as, due to this being the 'last' folder, it wasn't a rooted folder, just a simple folder.

You can only get the Self command for rooted folders. I'll try playing around with the folder and seeing if it's too much work to get everything re-arranged into a rooted folder and give it a try.

I'll get back to you with my findings (^_^)


Cheers.


*EDIT* I've tried using 'FindChildren', but couldn't, as it wouldn't then allow me to click on the element I was looking at. I've already tried 'FindChild', which although won't allow me to use my preferred 'PerformClick' command, will allow me to 'Click'...at first glance.

Using 'FindChild', I get the error findChild<T>(string) cannot be inferred, try specifying the type arguments explicitly.


*EDIT 2* Also, I'm getting the above explicitly issue when using just curly brackets. If I use square brackets [] like your example, I'm told I cannot apply indexing with [] to an expression of type 'method group'.

That being said, I think this is probably the right route to go down, just a way of writing it properly that it gets accepted :)

blackout
Posts: 14
Joined: Thu Mar 14, 2013 10:07 am

Re: Selecting first repository item

Post by blackout » Wed May 01, 2013 12:36 pm

Ok, I've figured out how to do it...but not really in the way I wanted to do it.

Rather than selecting the first item in my repository folder, I've modified the image RxPaths in the repository itself. They now aren't using their specific names, but instead using a rooted folder to link to a preceding hold-all, and index numbers to reference them indirectly.

Therefore, I can always just click on the first index (or whatever position I want) and it'll be the first indexed pictured...which will have the same effect. I hope...haha.

I'll let you all know if I end up breaking it somehow (^_^)


Cheers.