ajitjaiswal50 / selenium-vba

Automatically exported from code.google.com/p/selenium-vba
0 stars 0 forks source link

Can not switch frames #142

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Operating system and version (32/64bit) : Win 7 Professional 32bit
.Net Framework version : 4.0.30320
Office name and version(32/64bit) : Office 2010 Professional Plus 2010
Browser name and version : Firefox 35.0.1
SeleniumWrapper version : 1.0.2.0

What steps will reproduce the problem with a public website ?
1. I was not able to find a public site with a similar structure

I navigate to a page that has at least 4 frames.
There is on called "main" that has 2 frames inside called "menu" and "text".
I navigate to "menu", click a link, then i need to click a button in frame 
"text" and i can't switch frames.
Here is part of my code.

  sel.selectFrame ("main")
  sel.selectFrame ("menu")
  sel.Click "css=span.tree-label > img"
  sel.waitForPageToLoad (10000)
  sel.Click "//body[@id='document']/div[2]/div/div/span/img[2]"
  sel.waitForPageToLoad (10000)
  sel.Click "css=span.tree-label > a[title=""Tabela Resumo""]"
  sel.waitForPageToLoad (10000)

  sel.Click "//body[@id='document']/div[2]/div/div[2]/span/img[2]"
  sel.waitForPageToLoad (30000)
  sel.Click "xpath=(//a[contains(text(),'Report_Consumo')])"
  sel.waitForPageToLoad (30000)

Works fine till this point.

  sel.switchToFrame ("text")

Access says can't find frame "text"

  sel.findElementById("ok").Click
  sel.waitForPageToLoad (30000)

I want to click a button and then get back to the beginning of the process.
I have to do this 70 times.

Original issue reported on code.google.com by pemif...@gmail.com on 6 Mar 2015 at 12:52

GoogleCodeExporter commented 8 years ago
Have you tried with a timeout in case the frame is not yet created while the 
command is executed :
driver.switchToFrame "main", 3000

It could also mean that the current frame doesn't have the frame "text".
In this case you need reset the context:
driver.switchToDefaultContent

Can you provide the Html source code?

Original comment by florentbr on 6 Mar 2015 at 6:42

GoogleCodeExporter commented 8 years ago
Thank you for your quick and accurate replay.
My code now is:
  sel.selectFrame ("main")
  sel.selectFrame ("menu")
  sel.Click "css=span.tree-label > img"
  sel.waitForPageToLoad (10000)
  sel.Click "//body[@id='document']/div[2]/div/div/span/img[2]"
  sel.waitForPageToLoad (10000)
  sel.Click "css=span.tree-label > a[title=""Tabela Resumo""]"
  sel.waitForPageToLoad (10000)

  sel.Click "//body[@id='document']/div[2]/div/div[2]/span/img[2]"
  sel.waitForPageToLoad (30000)
  sel.Click "xpath=(//a[contains(text(),'Report_Consumo')])"
  sel.waitForPageToLoad (30000)
  sel.switchToDefaultContent
  sel.switchToFrame ("main")
  sel.switchToFrame "text"
  sel.findElementById("ok").Click
  sel.waitForPageToLoad (30000)

And works fine!
Problem solved!
Thank you very much!

Original comment by pemif...@gmail.com on 9 Mar 2015 at 10:27