Select value from drop-down - Python Webbot

838 views Asked by At

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

2

There are 2 answers

1
SeleniumUser On
driver.find_element_by_xpath("//select[@id='c7f1a59007dc1410af12f2ae7c1ed03d_select']/option[text()='Short description']").click()
0
lako65 On

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']")