Represents the frame control (<iframe> or <frame>). Default search finds the first occurring <iframe> or <frame> element.

Frame<TOwner>

Recommended to use for the cases when the frame page can be different in parent page.

Inherited from Control.

Supports [GoTemporarily] settings attribute.

Syntax

[ControlDefinition("*[self::iframe or self::frame]", ComponentTypeName = "frame")]
public class Frame<TOwner> : Control<TOwner>
    where TOwner : PageObject<TOwner>

Methods

public virtual TFramePageObject

SwitchTo<TFramePageObject>(TFramePageObject framePageObject = null, bool? temporarily = null)

where TFramePageObject : PageObject<TFramePageObject>

Switches to the frame page object represented by the instance of TFramePageObject type. If temporarily is to true, navigates temporarily preserving current page object state. If temporarily is not set, checks GoTemporarilyAttribute.

public TOwner

DoWithin<TFramePageObject>(Action<TFramePageObject> action, bool? temporarily = null)

where TFramePageObject : PageObject<TFramePageObject>

Switches to the frame page object, executes action(s) in scope of frame and switches back to the owner page object. If temporarily is to true, navigates temporarily preserving current page object state. If temporarily is not set, checks GoTemporarilyAttribute.

Example

<div>
    <iframe src="...">
        <html>
            <body>
                <input type="text" id="text-box">
            </body>
        </html>
    </iframe>
</div>
using Atata;
using _ = SampleApp.SamplePage;

namespace SampleApp
{
    public class SamplePage : Page<_>
    {
        public Frame<_> ContentFrame { get; private set; }
    }
}
using Atata;
using _ = SampleApp.FramePage;

namespace SampleApp
{
    public class FramePage : Page<_>
    {
        [FindById]
        public TextInput<_> TextBox { get; private set; }
    }
}
Go.To<SamplePage>().
    ContentFrame.SwitchTo<FramePage>(temporarily: true).
        TextBox.Set("abc").
        SwitchToRoot<SamplePage>().
    // Or use DoWithin method
    ContentFrame.DoWithin<FramePage>(
        x => x.TextBox.Should.Equal("abc"));

Frame<TFramePageObject, TOwner>

Recommended to use for the cases when the frame page is the same in parent page.

Inherited from Frame.

Supports [GoTemporarily] settings attribute.

Syntax

public class Frame<TFramePageObject, TOwner> : Frame<TOwner>
    where TOwner : PageObject<TOwner>
    where TFramePageObject : PageObject<TFramePageObject>

Methods

public TFramePageObject

SwitchTo(TFramePageObject framePageObject = null, bool? temporarily = null)

Switches to the frame page object represented by the instance of TFramePageObject type. If temporarily is to true, navigates temporarily preserving current page object state. If temporarily is not set, checks GoTemporarilyAttribute.

public TOwner

DoWithin(Action<TFramePageObject> action, bool? temporarily = null)

Switches to the frame page object, executes action(s) in scope of frame and switches back to the owner page object. If temporarily is to true, navigates temporarily preserving current page object state. If temporarily is not set, checks GoTemporarilyAttribute.

Example

<div>
    <iframe src="...">
        <html>
            <body>
                <input type="text" id="text-box">
            </body>
        </html>
    </iframe>
</div>
using Atata;
using _ = SampleApp.SamplePage;

namespace SampleApp
{
    public class SamplePage : Page<_>
    {
        public Frame<FramePage, _> ContentFrame { get; private set; }
    }
}
using Atata;
using _ = SampleApp.FramePage;

namespace SampleApp
{
    public class FramePage : Page<_>
    {
        [FindById]
        public TextInput<_> TextBox { get; private set; }

        public SamplePage SwitchBack()
        {
            return SwitchToRoot<SamplePage>();
        }
    }
}
Go.To<SamplePage>().
    ContentFrame.SwitchTo().
        TextBox.Set("abc").
        SwitchBack().
    // Or use DoWithin method
    ContentFrame.DoWithin(
        x => x.TextBox.Should.Equal("abc"));