33.切换窗口

场景

切换窗口的场景其实很普遍,当你点击了一个链接之后有可能弹出一个新窗口,这时候如果你需要定位新窗口中的元素并进行操作,你就需要进行窗口切换的操作。

switch_window.html

<html>
    <head>
        <title>Switch Window</title>
    </head>

    <body>
        <h3>This is main window</h3>
        <a id="open-new-window" href="sub_window.html" target="_blank">Click to open sub window</a>
    </body>
</html>

sub_window.html

<html>
    <head>
        <title>Sub Window</title>
    </head>

    <body>
        <h3>This is sub window</h3>
    </body>
</html>

注:switch_window.html和sub_window.html和test.py放在同一个文件夹下

创建test.py输入一下代码

猜你喜欢

转载自www.cnblogs.com/luoshuifusheng/p/9197855.html