Skip to content

Commit

Permalink
Remove the options on locator.isHidden
Browse files Browse the repository at this point in the history
It did accepts options which were strict and timeout. Strict is enabled
and cannot be changed when working with the locator API. Timeout is no
longer useful when working with isHidden.
  • Loading branch information
ankur22 committed Nov 23, 2023
1 parent 300e19b commit 5928ccd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
17 changes: 3 additions & 14 deletions common/locator.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,28 +246,17 @@ func (l *Locator) IsVisible() (bool, error) {

// IsHidden returns true if the element matches the locator's
// selector and is hidden. Otherwise, returns false.
func (l *Locator) IsHidden(opts goja.Value) (bool, error) {
l.log.Debugf("Locator:IsHidden", "fid:%s furl:%q sel:%q opts:%+v", l.frame.ID(), l.frame.URL(), l.selector, opts)
func (l *Locator) IsHidden() (bool, error) {
l.log.Debugf("Locator:IsHidden", "fid:%s furl:%q sel:%q", l.frame.ID(), l.frame.URL(), l.selector)

copts := NewFrameIsHiddenOptions()
if err := copts.Parse(l.ctx, opts); err != nil {
return false, fmt.Errorf("parsing is hidden options: %w", err)
}
hidden, err := l.isHidden(copts)
hidden, err := l.frame.isHidden(l.selector, &FrameIsHiddenOptions{Strict: true})
if err != nil {
return false, fmt.Errorf("checking is %q hidden: %w", l.selector, err)
}

return hidden, nil
}

// isHidden is like IsHidden but takes parsed options and does not
// throw an error.
func (l *Locator) isHidden(opts *FrameIsHiddenOptions) (bool, error) {
opts.Strict = true
return l.frame.isHidden(l.selector, opts)
}

// Fill out the element using locator's selector with strict mode on.
func (l *Locator) Fill(value string, opts goja.Value) {
l.log.Debugf(
Expand Down
2 changes: 1 addition & 1 deletion tests/locator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func TestLocatorElementState(t *testing.T) {
{
"hidden",
`() => document.getElementById('inputText').style.visibility = 'hidden'`,
func(l *common.Locator) bool { resp, _ := l.IsHidden(nil); return !resp },
func(l *common.Locator) bool { resp, _ := l.IsHidden(); return !resp },
},
{
"readOnly",
Expand Down

0 comments on commit 5928ccd

Please sign in to comment.