Find All, Find Next, Find Specific...
Posted: Mon Jul 25, 2011 3:16 pm
Hi,
I have been trying to get FindSingle or TryFindSingle to work for my situation and it works... sort of.
We have a deal site and the side bar displays all the "additional" deals. Unfortunately our the exact location of these frames to click to get to the deal varies by a DIV or so. I need to click the deals in the side bar.
I can get FindSingle and TryFindSingle to select the first deal but not subseqent deals - even when i drill down.
OR
Those code fragments work for the first deal. I can rely on the first set of DIVs to be the same for each deal so:
deal 1: /body/form/div[@id='bd']/div[@id='bd']/div[3]/div[2]/div[1]
deal 2: /body/form/div[@id='bd']/div[@id='bd']/div[3]/div[2]/div[2]
deal 3: /body/form/div[@id='bd']/div[@id='bd']/div[3]/div[2]/div[3]
Its just the remaining DIVs that vary.
When I try to make the variable webE for deal2 or deal3 it still finds deal1 even though it shouldn't be in that realm.
-- finds deal 1 again
Or if I try to make imgBuy the place where I give the more specific location - this errors out.
Am I not telling it where to look good enough? Is there another Find method that I am missing that would give me a Find All or a Find Specific (say using Index like in vbscript) or Find Next...
Thanks
Sierra
I have been trying to get FindSingle or TryFindSingle to work for my situation and it works... sort of.
We have a deal site and the side bar displays all the "additional" deals. Unfortunately our the exact location of these frames to click to get to the deal varies by a DIV or so. I need to click the deals in the side bar.
I can get FindSingle and TryFindSingle to select the first deal but not subseqent deals - even when i drill down.
Code: Select all
WebElement webE = "/dom[@domain='" + Domain + "']/body/form/div[@id='bd']/div[@id='bd']/div[3]/div[2]/div[1]/div/div";
WebElement imgBuy;
bool bFound = webE.TryFindSingle("//img[@alt='Buy']", out imgBuy);
imgBuy.Click();
Code: Select all
WebElement webE = "/dom[@domain='" + Domain + "']/body/form/div[@id='bd']/div[@id='bd']/div[3]/div[2]/div[1]/div/div/";
WebElement imgBuy = webE.FindSingle("//img[@alt='Buy']");
imgBuy.Click();
deal 1: /body/form/div[@id='bd']/div[@id='bd']/div[3]/div[2]/div[1]
deal 2: /body/form/div[@id='bd']/div[@id='bd']/div[3]/div[2]/div[2]
deal 3: /body/form/div[@id='bd']/div[@id='bd']/div[3]/div[2]/div[3]
Its just the remaining DIVs that vary.
When I try to make the variable webE for deal2 or deal3 it still finds deal1 even though it shouldn't be in that realm.
Code: Select all
WebElement webE = "/dom[@domain='" + Domain + "']/body/form/div[@id='bd']/div[@id='bd']/div[3]/div[2]/div[2]/div/div/";
WebElement imgBuy = webE.FindSingle("//img[@alt='Buy']");
imgBuy.Click();
Or if I try to make imgBuy the place where I give the more specific location - this errors out.
Code: Select all
WebElement webE = "/dom[@domain='" + Domain + "']/body/form/div[@id='bd']/div[@id='bd']/div[3]/div[2]";
WebElement imgBuy = webE.FindSingle("//div[2]/div/div/img[@alt='Buy']");
imgBuy.Click();
Thanks
Sierra