【问题标题】:What is the name of the page element that reads "+ Add telephone" on the Google Hangouts start page?Google Hangouts 起始页上显示“+ 添加电话”的页面元素的名称是什么?
【发布时间】:2015-05-14 03:23:41
【问题描述】:
我正在寻找 Google Hangouts start page 上显示为“+ 添加电话”的页面元素的名称,以便将其插入 Selenium Python API 的 webdriver.Firefox().find_element_by_name() 命令。
或者,元素 ID 也可以使用,因为我知道还有一个 find_element_by_id() 命令。
【问题讨论】:
标签:
python
html
selenium
selenium-webdriver
hangout
【解决方案1】:
该元素没有任何名称。 Go for xpath contains 函数并使用find_element_by_xpath
//div[contains(text(),'Add telephone')]
但是,最好不要使用 Google 进行任何类型的测试。那是一种陷阱。专门用于硒
【解决方案2】:
检查元素(使用谷歌浏览器),它看起来像这样:
<div class="c-N-K c-za-b ZG Kn-Mo" role="button" tabindex="0" style="-webkit-user-select: none;">+ Add telephone</div>
该元素上没有name 或id。但它被包裹在一个span 中,该id 具有唯一的id!
<span id=":sb.og">
<div class="c-N-K c-za-b ZG Kn-Mo" role="button" tabindex="0" style="-webkit-user-select: none;">+ Add telephone</div>
</span>
或者,正如@Saifur 指出的那样,您也可以通过文本查找。