selenium 运行网页中js脚本报错,提示未定义 财富值47

2016-10-25 19:56发布

问题1

selenium 运行网易中js脚本报错提示未定义
报错提示如下:

driver.execute_script("javascript:amsInit(62800,303153);");  error: selenium.common.exceptions.WebDriverException: Message: ReferenceError: amsInit is not defined

js函数是个链接,点击后打开天涯明月刀的选择服务器大区窗口,按钮的代码如下:

<a href="javascript:amsInit(62800, 303153);">【绑定大区】</a>

firefox控制台运行 amsInit(62800, 303153); 有效能正常打开选择大区窗口,但会提示未定义,如下:

firefox控制台运行  >>amsInit(62800,303153) <-undefined

请问直接调用网页中的类似js脚本,需要如何实现?

问题2:

代码如下一个的一个选择窗口,如何用selenium操作

<li style="display:inline;" class="area_select_li"><select id="area1ContentId_wuxia"><option value="">请选择大区</option><option value="7609515">青龙乱舞</option><option value="7609516">大地飞鹰</option><option value="7609559">血海飘香</option><option value="7609560">名剑风流</option><option value="7609617">陌上花开</option><option value="7609705">天命风流</option></select><select id="areaContentId_wuxia"><option value="">请选择服务器</option></select></li>

尝试一下方法均不可选中

使用Select方法无效

Select(driver.find_element_by_id("area1ContentId_wuxia")).select_by_value("7609705")

遍历option,使用click方法无效

allOptions = select.find_elements_by_tag_name("option") for option in allOptions:     print "Value is: " + option.get_attribute("value") + "Text is:"+ option.text     option.click()     break


请问如上的选择应该如何操作?

友情提示: 问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
0条回答