WebDriver无法找到元素.但是它位于我直接访问网页时的位置 [英] WebDriver is unable to locate elements. But it locates when i directly access the webpage

查看:125
本文介绍了WebDriver无法找到元素.但是它位于我直接访问网页时的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自动化:预订公交车票
说明:

  1. WebDriver 无法在我进入 网页( passengerDetails )

但是当我直接访问该页面( passengerDetails )时,它会定位 元素.

But when i access that page (passengerDetails) directly, it locates the elements.

注意:访问 SearchBus-> SelectBus-> SelectSeat-> PassengerDetails -无法找到..
直接访问 PassengerDetails -可以定位..我想这是因为URL从 http更改为https .无论如何,我为此建议一个解决方案.

Note: Accessing SearchBus->SelectBus->SelectSeat->PassengerDetails - Unable to locate..
Accessing directly PassengerDetails -Able to Locate.. I guess, this is since the URL changes from http to https. Anyhow suggest me a solution for this..

推荐答案

因此,您的网站肯定使用了iframe类型.基本上,要使代码正常工作,您需要从"iframe"切换回您的网站. 尝试此代码

So your site is definitely using iframe type. Basically to make your code work, you need to switch back from "iframe" to your site. try this code

driver.switchTo().defaultContent();

这篇关于WebDriver无法找到元素.但是它位于我直接访问网页时的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆