简体   繁体   English

单击并使用python 2 selenium选择javascript下拉菜单的值

[英]click and select value of javascript drop down menu using python 2 selenium

I am trying to click on following code and select value "SLAHOLD" 我正在尝试单击以下代码,然后选择值“ SLAHOLD”

<div aria-live="polite" id="mx5050_holder" class="bc"><input aria-required="true" role="combobox" aria-autocomplete="none" id="mx5050" class="fld text cbt  ibfld fld_req" ctype="textbox" li="mx5051" liclick="1" maxlength="10" style=";width:75.0px;" sue="1" readonly="readonly" type="text" title="New Status" value="" ov="" work="1" fldinfo="{&quot;length&quot;:&quot;10&quot;,&quot;inttype&quot;:&quot;1&quot;,&quot;eventpriority&quot;:1,&quot;required&quot;:true}" originalvalue="" prekeyvalue="" stoptcclick="false" keydown="true"></div>

Here is javascript code, which I need to select from above menu: 这是JavaScript代码,我需要从上面的菜单中选择:

javascript: topLevelMenus['shared'].menuClick({"id":"0_SLAHOLD_OPTION","text":"SLA Hold","value":"0_SLAHOLD_OPTION","target":"incident_STATUS_menus","event":"click"});

I tried few options but it rather does nothing, here is what I got now: 我尝试了几种选择,但它什么都不做,这是我现在得到的:

driver.find_element_by_xpath("//*[@id='mx5050']").click()   
time.sleep(2)
driver.find_element_by_xpath("//*[@id='menuholdertd']").click()  
time.sleep(2)

Python version is 2.7.5 Python版本是2.7.5

Many thanks in advance. 提前谢谢了。

Regardless of my earlier comments, what happens if you try sending these keys to the combobox: 无论我之前的评论如何,如果尝试将这些密钥发送到组合框,将会发生什么:

elem = driver.find_element_by_id("mx5050")

elem.send_keys("SLA Hold")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM