How Selenium works(elements status/2:Chrome)

2020-07-29

Overview

Test page

Google Chrome

83.0.4103.116(64bit)
Version 83.0.4103.116(64bit)

Button

Click

First, enter the id of the element in the locator field and press the “id" button. Next, press the “click" button.
If successful, the executed code of Python is displayed.

Normal

It is clickable.

Click event occurs
Click event occurred

Inactive(disabled)

It is clickable, but the screen does not respond.

No response
No response

Inactive(pointer-events:none)

Exception occurred.

Get the element
Get element
Exception occurred
Exception occurred
Message
ElementClickInterceptedExceptionMessage: element click intercepted: Element <input type="submit" id="submit3" value="submit" class="btn-submit" style="pointer-events:none;" tabindex="-1" onclick="element_click('submit3!')"> is not clickable at point (831, 445). Other element would receive the click: <div>...</div> 
(Session info: chrome=83.0.4103.116) 
<traceback object at 0x0000019291713EC8>

Read-only(readonly)

A click event occurs.

Click event occurs
Click event occurred

Hidden(display:none)

Exception occurred.

Get the element
Get element
Exception occurred
Exception occurred
Message
ElementNotInteractableExceptionMessage: element not interactable 
(Session info: chrome=83.0.4103.116) 
<traceback object at 0x000001929171CB48>

Hidden(visibility:hidden)

Exception occurred, just like “display:none".

Get the element
Get element
Exception occurred
Exception occurred

Result

Button click note
normal OK  
disabled NG No response
pointer-events:none Ex  
readonly OK  
display:none Ex  
visibility:hidden Ex  

Even if it is operated manually, the click event will occur in “normal" and “readonly", which matches the Selenium results.

Note

If you try to manipulate the following elements before closing the dialog, an Selenium exception occurs.

Get the element before closing the dialog.
Exception occurred
Message
UnexpectedAlertPresentExceptionAlert Text: submit4!
Message: unexpected alert open: {Alert text : submit4!}
  (Session info: chrome=83.0.4103.116)
<traceback object at 0x00000139E9F18EC8>

Get Attribute

Get the visibility, the active state (enabled/disabled), and the read-only attributes of the element.

Normal

Input the following codes, and press the “Code" button.

print(driver.find_element_by_id('submit1').is_displayed())
print(driver.find_element_by_id('submit1').is_enabled())
print(driver.find_element_by_id('submit1').get_attribute("readonly"))
Get the attribute
displayed:True / enabled:True / readonly:None

Inactive(disabled)

Get the attribute
displayed:True / enabled:False / readonly:None

Inactive(pointer-events:none)

Get the attribute
displayed:True / enabled:True / readonly:None

Read-only(readonly)

Get the attribute
displayed:True / enabled:True / readonly:true

Hidden(display:none)

Get the attribute
displayed:False / enabled:True / readonly:None

Hidden(visibility:hidden)

Get the attribute
displayed:False / enabled:True / readonly:None

Result

Button is_displayed() is_enabled() readonly
normal True True None
disabled True False None
pointer-events:none True True None
readonly True True true
display:none False True None
visibility:hidden False True None
  • “readonly" is an HTML attribute, so the return value is “true(lowercase)" or “None".
  • It is “is_displayed() =False" in “display:none" and “visibility:hidden", but the active state is “is_enabled() =True".

Link

Click

Normal

Click event occurs
Click event occurred

Inactive(disabled)

There is no “disabled" attribute for <a> tag. That is invalid.

Click event occurs
Click event occurred

You can also click it manually.

Click event occurs
Click event occurred

Inactive(pointer-events:none)

Exception occurred
Exception occurred

Read-only(readonly)

Click event occurs
Click event occurred

Hidden(display:none)

Exception occurred
Exception occurred

Hidden(visibility:hidden)

Exception occurred
Exception occurred

Result

Link click note
normal OK  
disabled OK  
pointer-events:none Ex  
readonly OK  
display:none EX  
visibility:hidden Ex  

Get Attribute

Normal

Get the attribute
displayed:True / enabled:True / readonly:None

Inactive(disabled)

“is_enabled() = True": There is no “disabled" attribute for tag.

Get the attribute
displayed:True / enabled:True / readonly:None

Inactive(pointer-events:none)

Get the attribute
displayed:True / enabled:True / readonly:None

Read-only(readonly)

Get the attribute
displayed:True / enabled:True / readonly:true

Hidden(display:none)

Get the attribute
displayed:False / enabled:True / readonly:None

Hidden(visibility:hidden)

Get the attribute
displayed:False / enabled:True / readonly:None

Result

Link is_displayed() is_enabled() readonly
normal True True None
disabled True True None
pointer-events:none True True None
readonly True True true
display:none False True None
visibility:hidden False True None

Text

Send_keys

Normal

After getting the element, press the “send_key" button. “hoge" is entered.

send_keys
send_key

Inactive(disabled)

Exception occurred
Exception occurred

Inactive(pointer-events:none)

Enterable with selenium.

send_keys
send_key

Not clickable and unable to enter due to “tabindex = -1" specification, so it is impossible to input characters with manually.

Exception occurred
Not clickable

Read-only(readonly)

Nothing is entered.

No response
No response

Hidden(display:none)

Exception occurred
Exception occurred

Hidden(visibility:hidden)

Exception occurred
Exception occurred

Get value

Gets the contents of the text by “get_attribute('value’)“.  

Normal

“hoge" is returned.

hoge
Get value

Inactive(disabled)

The input value is empty, but the value can be retrieved.

""
Get value

Inactive(pointer-events:none)

“hoge" is returned.

hoge
Get value

Read-only(readonly)

The input value is empty, but the value can be retrieved.

""
Get value

Hidden(display:none)

The input value is empty, but the value can be retrieved.

""
Get value

Hidden(visibility:hidden)

The input value is empty, but the value can be retrieved.

""
Get value

Result

Text send_keys get value note
normal OK OK  
disabled Ex OK  
pointer-events:none OK OK Not enterable manually
readonly NG OK  
display:none Ex OK  
visibility:hidden Ex OK  

Get Attribute

Normal

Get the attribute
displayed:True / enabled:True / readonly:None

Inactive(disabled)

Get the attribute
displayed:True / enabled:False / readonly:None

Inactive(pointer-events:none)

Get the attribute
displayed:True / enabled:True / readonly:None

Read-only(readonly)

Get the attribute
displayed:True / enabled:True / readonly:true

Hidden(display:none)

Get the attribute
displayed:Fasle / enabled:True / readonly:None

Hidden(visibility:hidden)

Get the attribute
displayed:Fasle / enabled:True / readonly:None

Result

Text is_displayed() is_enabled() readonly
normal True True None
disabled True False None
pointer-events:none True True None
readonly True True true
display:none False True None
visibility:hidden False True None

Select

Select item

Normal

After getting the element, press the “select" button. The second item is selected.

option2
option2

Inactive(disabled)

Not selectable.

No response
No response

Inactive(pointer-events:none)

Not selectable.

No response
No response

Read-only(readonly)

Selectable

option2
option2

Hidden(display:none)

Exception occurred

Exception occurred
Exception occurred
ElementNotInteractableExceptionMessage: element not interactable: Element is not currently visible and may not be manipulated
  (Session info: chrome=83.0.4103.116)
<traceback object at 0x00000150CF496E08>

Hidden(visibility:hidden)

Exception occurred

Exception occurred
Exception occurred

Get selected item

Normal

Input the following codes, and press the “Code" button.

select = Select(driver.find_element_by_id('select1'))
option = select.first_selected_option
print(option.text)

“option2" is displayed.

option2
option2

Inactive(disabled)

“option1" is displayed.

option1
option1

Inactive(pointer-events:none)

“option1" is displayed.

option1
option1

Read-only(readonly)

“option2" is displayed.

option2
option2

Hidden(display:none)

An empty character is returned.

""
Empty

The item specified with <option> becomes an empty character.

option item
option1~3:empty, option4:index out of range

Hidden(visibility:hidden)

An empty character is returned.

""
Empty

Result

Select Select item get Selected item note
normal OK OK  
disabled NG OK  
pointer-events:none NG OK  
readonly OK OK  
display:none Ex NG* *Empty is returned
visibility:hidden Ex NG* *Empty is returned

Get Attribute

Normal

Get the attribute
displayed:True / enabled:True / readonly:None

Inactive(disabled)

Get the attribute
displayed:True / enabled:False / readonly:None

Inactive(pointer-events:none)

Get the attribute
displayed:True / enabled:True / readonly:None

Read-only(readonly)

Get the attribute
displayed:True / enabled:True / readonly:true

Hidden(display:none)

Get the attribute
displayed:False / enabled:True / readonly:None

Hidden(visibility:hidden)

Get the attribute
displayed:False / enabled:True / readonly:None

Result

Select is_displayed() is_enabled() readonly
normal True True None
disabled True False None
pointer-events:none True True None
readonly True True true
display:none False True None
visibility:hidden False True None

Select(option)

Inspect for option2

Select item

Normal

“option2" is selected.

option2
option2

Inactive(disabled)

Not selectable.

No response
No response

Not selectable manually.

option2 is inactive
Can’t select option2

Inactive(pointer-events:none)

Not selectable.

No response
No response

You can select “option2" manually.

option2
option2

Read-only(readonly)

“option2" is selected.

option2
option2

Hidden(display:none)

“option2" is selected.

option2
option2

You cannot select “option2" manually.

Hide option2
option2 is hidden

Hidden(visibility:hidden)

“option2" is selected.

option2
option2

You cannot select “option2" manually.

Hide option2
option2 is hidden

Get selected item

Normal

option2
option2

Inactive(disabled)

“option4" is disabled with “disabled", and selected with “selected".

“option4" is displayed.

option4
option4

Inactive(pointer-events:none)

option2
option2

Read-only(readonly)

option2
option2

Hidden(display:none)

option2
option2

Hidden(visibility:hidden)

option2
option2

Result

Select(option) Select item get selected item note
normal OK OK  
disabled NG OK  
pointer-events:none *NG OK *Selectable manually
readonly OK OK  
display:none *OK OK *Not selectable manually
visibility:hidden *OK OK *Not selectable manually

Get Attribute

Normal

Input the following codes, and press the “Code" button.

select = Select(driver.find_element_by_id('select11'))
option = select.options[1]
print(option.text)
print(option.is_displayed())
print(option.is_enabled())
print(option.get_attribute('readonly'))
Get the attribute
displayed:True / enabled:True / readonly:None

Inactive(disabled)

Get the attribute
displayed:True / enabled:False / readonly:None

Inactive(pointer-events:none)

Get the attribute
displayed:True / enabled:True / readonly:None

Read-only(readonly)

Get the attribute
displayed:True / enabled:True / readonly:true

Hidden(display:none)

Although “option2" is hidden, “is_displayed" is “True".

Get the attribute
displayed:True / enabled:True / readonly:None

Hidden(visibility:hidden)

Although “option2" is hidden, “is_displayed" is “True".

Get the attribute
displayed:True / enabled:True / readonly:None
Result
Select(option) is_displayed() is_enabled() readonly
normal True True None
disabled True False None
pointer-events:none True True None
readonly True True true
display:none True True None
visibility:hidden True True None

Radio

Click

Normal

Radio_1
Radio_1

Inactive(disabled)

No response
No response

Inactive(pointer-events:none)

Exception occurred.

Exception occurred
Exception occurred.
ElementClickInterceptedExceptionMessage: element click intercepted: Element <input type="radio" id="radio_3" name="radio" style="pointer-events:none;" tabindex="-1"> is not clickable at point (800, 430). Other element would receive the click: <div>...</div>
  (Session info: chrome=83.0.4103.116)
<traceback object at 0x000002C15EFB8F48>

Read-only(readonly)

It is clickable.

Radio_4
Radio_4

Hidden(display:none)

Exception occurred.

Exception occurred
Exception occurred.

Message

ElementNotInteractableExceptionMessage: element not interactable
  (Session info: chrome=83.0.4103.116)
<traceback object at 0x000002C15EFB6488>

Hidden(visibility:hidden)

Exception occurred.

Exception occurred
Exception occurred.

Get value

Normal

True
True

Inactive(disabled)

False
False

Inactive(pointer-events:none)

False
False

Read-only(readonly)

True
True

Hidden(display:none)

False
False

Hidden(visibility:hidden)

False
False

Behavior when label is clicked

The Radio button is specified “label for", so you can check it by clicking label.

Normal

Enter the XPath obtained by XPathGetter in the locator field and press the “XPath" button.
The escaped code to get the label element is outputted.

Get the element
Get the label element with XPath.

Input the following codes, and press the “Code" button.

driver.find_element_by_xpath('//label[contains(text(),\'Radio_1\')]').click()
print(driver.find_element_by_id('radio_1').is_selected())
radio_1=True
Radio_1=True

Inactive(disabled)

Not checkable by clicking label.

radio_2=False
Radio_2=False

Inactive(pointer-events:none)

radio_3=True
Radio_3=True

Read-only(readonly)

radio_4=True
Radio_4=True

Hidden(display:none)

It is not displayed, but the button is checked by clicking the label.

radio_5=True
Radio_5=True

Hidden(visibility:hidden)

It is not displayed, but the button is checked by clicking the label.

radio_6=True
Radio_6=True

Result

Radio click radio click label get value
normal OK OK OK
disabled NG NG OK
pointer-events:none Ex OK OK
readonly OK OK OK
display:none Ex OK OK
visibility:hidden Ex OK OK

Get Attribute

Normal

Get the attribute
displayed:True / enabled:True / readonly:None

Inactive(disabled)

Get the attribute
displayed:True / enabled:False / readonly:None

Inactive(pointer-events:none)

Get the attribute
displayed:True / enabled:True / readonly:None

Read-only(readonly)

Get the attribute
displayed:True / enabled:True / readonly:true

Hidden(display:none)

Get the attribute
displayed:False / enabled:True / readonly:None

Hidden(visibility:hidden)

Get the attribute
displayed:False / enabled:True / readonly:None

Result

Radio is_displayed() is_enabled() readonly
normal True True None
disabled True False None
pointer-events:none True True None
readonly True True true
display:none False True None
visibility:hidden False True None

CheckBox

Click

Normal

Check_1
Check_1

Inactive(disabled)

No response
No response

Inactive(pointer-events:none)

Exception occurred
Exception occurred

Read-only(readonly)

Check_4
Check_4

Hidden(display:none)

Exception occurred
Exception occurred

Hidden(visibility:hidden)

Exception occurred
Exception occurred

Get value

Normal

True
True

Inactive(disabled)

False
False

Inactive(pointer-events:none)

False
False

Read-only(readonly)

True
True

Hidden(display:none)

False
False

Hidden(visibility:hidden)

False
False

Behavior when label is clicked

The checkbox is specified “label for", so you can check it by clicking label.

Normal

Input the following codes, and press the “Code" button.

driver.find_element_by_xpath('//label[contains(text(),\'Check_1\')]').click()
print(driver.find_element_by_id('check_1').is_selected())
Check_1=True
Check_1=True

Inactive(disabled)

Check_2=False
Check_2=False

Inactive(pointer-events:none)

Check_3=True
Check_3=True

Read-only(readonly)

Check_4=True
Check_4=True

Hidden(display:none)

It is not displayed, but the button is checked by clicking the label.

Check_5=True
Check_5=True

Hidden(visibility:hidden)

It is not displayed, but the button is checked by clicking the label.

Check_6=True
Check_6=True

Result

CheckBox click checkbox click label get value
normal OK OK OK
disabled NG NG OK
pointer-events:none Ex OK OK
readonly OK OK OK
display:none Ex OK OK
visibility:hidden Ex OK OK

Get Attribute

Normal

Get the attribute
displayed:True / enabled:True / readonly:None

Inactive(disabled)

Get the attribute
displayed:True / enabled:False / readonly:None

Inactive(pointer-events:none)

Get the attribute
displayed:True / enabled:True / readonly:None

Read-only(readonly)

Get the attribute
displayed:True / enabled:True / readonly:true

Hidden(display:none)

Get the attribute
displayed:False / enabled:True / readonly:None

Hidden(visibility:hidden)

Get the attribute
displayed:False / enabled:True / readonly:None

Result

CheckBox is_displayed() is_enabled() readonly
normal True True None
disabled True False None
pointer-events:none True True None
readonly True True true
display:none False True None
visibility:hidden False True None