0

Hi All, I'm tring to select a value from drop-down list but its not working.

This is the dropdown that Im trying to select

This is the dropdown that Im trying to select

Below is my script.

'''

from webbot import Browser
import time

web = Browser()
web.go_to('https://*****.service-now.com/')
web.type('*****\t')
web.type('*****\t\t')
web.type(web.Key.ENTER)
web.maximize_window()
web.click('Incident', tag='span')
time.sleep(25)
web.click('Open - Unassigned', tag='div')
time.sleep(5)
web.click('Short description', value='short_description')

'''

Below is copied element of drop-down

copy element:

<select id="c7f1a59007dc1410af12f2ae7c1ed03d_select" class="form-control default-focus-outline"> 
<option value="zztextsearchyy" selected="SELECTED" role="option">for text</option><option 
value="number" role="option">Number</option><option value="opened_at" role="option">Opened</option> 
<option value="short_description" role="option">Short description</option><option value="caller_id" 
role="option">Caller</option><option value="priority" role="option">Priority</option><option 
value="state" role="option">State</option><option value="category" role="option">Category</option> 
<option value="assignment_group" role="option">Assignment group</option><option value="assigned_to" 
role="option">Assigned to</option><option value="sys_updated_on" role="option">Updated</option> 
<option value="sys_updated_by" role="option">Updated by</option></select>

Xpath: (If needed)

//*[@id="c7f1a59007dc1410af12f2ae7c1ed03d_select"]

When tried to run the code gave me below error.

DevTools listening on ws://127.0.0.1:64454/devtools/browser/570915fb-92df-4ce0-97ed-6d20c8efd860
[5772:10264:0417/003932.575:ERROR:browser_switcher_service.cc(238)] XXX Init()
Traceback (most recent call last):
File "WebAut.py", line 14, in <module>
web.click('Short description', value='short_description')
TypeError: click() got an unexpected keyword argument 'value'

PLEASE Assist on this

Ajanyan Pradeep
  • 1,097
  • 1
  • 16
  • 26
Pawan
  • 1
  • 2
  • May this help [this](https://stackoverflow.com/questions/6430462/how-to-select-get-drop-down-option-in-selenium-2) or this [here](https://sqa.stackexchange.com/questions/38194/selenium-python-drop-down-menu-select) – Björn Apr 17 '20 at 05:57

2 Answers2

0
driver.find_element_by_xpath("//select[@id='c7f1a59007dc1410af12f2ae7c1ed03d_select']/option[text()='Short description']").click()
SeleniumUser
  • 4,065
  • 2
  • 7
  • 30
  • Hi @Dipak bachhav thanks for the suggestion. Im not using selenium. Im using Webbot along with python so this would not work. Any other suggestion on this. And sorry I forgot to mention that ID for drop-down keeps changing. I tried using classname too but it didn'nt worked. – Pawan Apr 17 '20 at 06:36
0

I had this same question. For Webbot specifically, this is what worked for me:

web.click(xpath="//select[@id='c7f1a59007dc1410af12f2ae7c1ed03d_select']/option[text()='Short description']")
lako65
  • 11
  • 2