Reputation: 288
I'm using Selenium's Ruby bindings and I'm trying to make the WebDriver switch to an iFrame which is identifiable only by a class attribute.
Essentially I'm trying to achieve the equivalent of this Java code:
driver.switchTo().frame(driver.findElement(By.className("my-iframe-class")));
but I fail to do so since the Ruby wrapper only accepts id or name attributes in
driver.switch_to.frame('some-id-or-name')
Any suggestions on how I can switch frame by class in Ruby?
Here's a sample HTML:
<html>
<head></head>
<body>
<iframe class="my-iframe-class">
<p>iframe body</p>
</iframe>
</body>
</html>
Upvotes: 4
Views: 5416
Reputation: 2148
The ruby docs on github say you can do:
driver.switch_to.frame driver.find_element(:class, 'some-frame') # frame element
Note that I have not used the ruby bindings so I cannot tell you if this is correct.
Upvotes: 3