我尝试使用Selenium python将一些文本发送到Google Adwords Keyplanner tool的搜索文本区域。
手动输入textarea中的文本时,会转到其属性' title'。 textarea看起来像这样:
<textarea class="spl-a sprb-c spl-d" rows="1" id="gwt-debug-keywords-text-area" aria-labelledby="gwt-uid-94 gwt-uid-74" wrap="off" style="overflow: hidden;" dir="ltr" title="mytext"></textarea>
结果:
driver.find_element_by_tag_name('textarea').send_keys('mytext')
或
driver.find_element_by_id('gwt-debug-keywords-text-area').send_keys('mytext')
产生
selenium.common.exceptions.ElementNotVisibleException: Message: element not visible
是否有另一种方法可以将密钥发送到此搜索文本区域?我有500个关键字,我需要抓取数据。
文本区域的完整代码:
<div class="spl-c spI-d" style="width: 575px;">
<div id="gwt-uid-119" class="sprb-a">
<div class="sprb-b spl-b" style="display: none;" aria-hidden="true">For example, flowers or used cars</div>
<textarea id="gwt-debug-keywords-text-area" class="spl-a sprb-c spl-d" rows="1" aria-labelledby="gwt-uid-139 gwt-uid-119" style="overflow: hidden;" dir="ltr" title="my keyword" wrap="off"></textarea>
</div>
</div>
</div>
答案 0 :(得分:0)
你试图与之交互的元素只能由Selenium寻址,因为它位于隐藏的div中 - 这个:
DateTime date1 = somevalue;
DateTime date2 = someothervalue;
TimeSpan difference = date2 - date1;
还有另一个元素实际上是用户的输入 - 使用按键事件处理程序查找元素,以及您输入字符的DOM网页中的更改。