使用隐藏的选择elemens在分裂(和硒) [英] Work with hidden select elemens in splinter (and selenium)
本文介绍了使用隐藏的选择elemens在分裂(和硒)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个分裂的问题。我尝试执行此代码:
# - * - 编码:utf-8 - * -
浏览器
browser = Browser()
browser.visit('https://passport.yandex.com/registration/mail')
browser.find_by_name(hint_question_id) .click()
browser.select(hint_question_id,12)
得到此错误:
selenium.common.exceptions.ElementNotVisibleException:消息:u'Element当前不可见,因此可能不互动; Stacktrace:
at fxdriver.preconditions.visible(file:/// c:/users/dm/appdata/local/temp/tmppiwmlb/extensions/fxdriver@googlecode.com/components/command_processor.js:8791:5 )
我尝试使用selenium:
# - * - 编码:utf-8 - * -
从selenium import webdriver
从selenium.webdriver.support.ui import选择
driver = webdriver.Firefox()
driver.get(https://passport.yandex.com/registration/mail)
driver.find_element_by_name(hint_question_id)。点击()
#导航到页面
select = Select(driver.find_element_by_tag_name(select))
print select.options
print [o.text for o in select.options]#these are string-s
select.select_by_index('2')
$ b b
但得到相同的错误:
selenium.common.exceptions.ElementNotVisibleException:消息:u'Element目前不可见,所以不可与'互动'; Stacktrace:
at fxdriver.preconditions.visible(file:/// c:/users/dm/appdata/local/temp/tmpzjqnnp/extensions/fxdriver@googlecode.com/components/command_processor.js:8791:5 )
我做错了什么?谢谢。
解决方案
我找到解决方案。这个网站使用pseudo选择。
browser.find_by_name(hint_question_id)click()
需要写
browser.find_by_css li [role = \presentation\][1] .click()
browser.find_by_id(hint_answer)。fill(firstname)
工作良好。
I have a problem with splinter. I try to execute this code:
# -*- coding: utf-8 -*- from splinter import Browser browser = Browser() browser.visit('https://passport.yandex.com/registration/mail') browser.find_by_name("hint_question_id").click() browser.select("hint_question_id","12")
But get this error:
selenium.common.exceptions.ElementNotVisibleException: Message: u'Element is not currently visible and so may not be interacted with' ; Stacktrace: at fxdriver.preconditions.visible (file:///c:/users/dm/appdata/local/temp/tmppiwmlb/extensions/fxdriver@googlecode.com/components/command_processor.js:8791:5)
I try to use selenium:
# -*- coding: utf-8 -*- from selenium import webdriver from selenium.webdriver.support.ui import Select driver = webdriver.Firefox() driver.get("https://passport.yandex.com/registration/mail") driver.find_element_by_name("hint_question_id").click() # navigate to the page select = Select(driver.find_element_by_tag_name("select")) print select.options print [o.text for o in select.options] # these are string-s select.select_by_index('2')
But get the same error:
selenium.common.exceptions.ElementNotVisibleException: Message: u'Element is not currently visible and so may not be interacted with' ; Stacktrace: at fxdriver.preconditions.visible (file:///c:/users/dm/appdata/local/temp/tmpzjqnnp/extensions/fxdriver@googlecode.com/components/command_processor.js:8791:5)
What am I doing wrong? Thanks.
解决方案I find the solution. This site use pseudo select. For Splinter after:
browser.find_by_name("hint_question_id").click()
needs write
browser.find_by_css("li[role=\"presentation\"]")[1].click() browser.find_by_id("hint_answer").fill(firstname)
Work good.
这篇关于使用隐藏的选择elemens在分裂(和硒)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文