cancel
Showing results for 
Search instead for 
Did you mean: 

Clicking a span button

Highlighted
Contributor

Clicking a span button

Hi,

 

I have a span button on the webpage with this code

 

 

<span class="ui-autocomplete-icon searchmode" id="Schedule-00-Row471b178a-49c2-499d-828e-f0cac7690899E-Icon"></span>

 

I use this Javascript code in TC to point to that span button 

 

 

Page = Sys.Browser('*').Page("www.myweb.com");
var button = page.QuerySelector("span.searchmode");

 

Var button successfully find that span button. 

 

But when I do this 

 

 

button.ClickButton();

or 

button.Click();

 

TC complains that 

TypeError
button.ClickButton is not a function

or 

TypeError
button.Click is not a function

wondering why TC cannot click that button Man Sad 

 

Thanks. 

 

Tags (2)
3 REPLIES 3
Community Hero

Re: Clicking a span button

If you use the whole name of the button instead of the variable, does the click work?  

Contributor

Re: Clicking a span button

Thanks @Marsha_R.  

 

Not sure if I understand your comment correctly. That one line of HTML is the one that creates that button.

I just use QuerySelector() to grab the whole line and then apply Click().

 

I use this method to Click() other buttons and it works, just this span button doesn't work Man Sad 

Community Hero

Re: Clicking a span button

You have

Page = Sys.Browser('*').Page("www.myweb.com");
var button = page.QuerySelector("span.searchmode");

and

button.ClickButton();

or 

button.Click();

 but what happens if you do this instead?

Sys.Browser('*').Page(www.myweb.com).QuerySelector("span.searchmode").ClickButton()

 

For troubleshooting, you want to take all the variables out and first see if you can actually click the button.  Then we can see how to plug the variables in.

New Here?
Join us and watch the welcome video:
Watch the New Interview
APITestingMistake#2
Top Kudoed Authors