Current time: 10-23-2019, 03:13 AM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to select elements with class names
11-09-2015, 11:11 PM
Post: #1
How to select elements with class names
Hi,

After login into my application i need to click on one linke "Select All". The code for this select all is as below

<a class="ds-app-pointer-plain option-vertically-center option-text ng-binding" data-ng-click="selectAll()">Select All</a>

I have tried in different ways to select the linke "Select All" using webpage but unable to click on the link.

Tried like
clickAndWait innerText'Select All
clickAndWait innerText="Select All"
clickAndWait innerText=Select All
clickAndWait document.querySelector('a[href*="Select All"]').click()
clickAndWait document.querySelector('.ds-app-pointer-plain option-vertically-center option-text ng-binding').click()
etc.

Can you help us the webpage script line for the same....

Thanks,
Vijay
Find all posts by this user
Quote this message in a reply
11-10-2015, 10:14 AM (This post was last modified: 11-10-2015 10:15 AM by rviscomi.)
Post: #2
RE: How to select elements with class names
The input to clickAndWait is attribute=value. In your HTML code, there are only two attributes: class and data-ng-click. If there are no other elements with that combination of class names, you could target the Select All element with this pair:

clickAndWait class="ds-app-pointer-plain option-vertically-center option-text ng-binding"

Although I'm not sure if this will work because of the quotes. Omitting them might not work either because of the spaces.

So you can try the second attribute, data-ng-click:

clickAndWait data-ng-click=selectAll()

But again, this might not work because of the parentheses. You'll have to try it to be sure.


If all else fails, you could use querySelector like you attempted. However, clickAndWait only takes an attribute=value pair. So you'll need a different command. execAndWait will take an arbitrary JS statement and execute it. Here's something that might be more robust:

execAndWait document.querySelector('a[data-ng-click="selectAll()"]').click()

All of this would be made so much easier if the element you want to click on had a concise ID. For example if it looked like <a id="select-all" ...>Select All</a> you could simply write:

clickAndWait id=select-all
Visit this user's website Find all posts by this user
Quote this message in a reply
11-10-2015, 09:18 PM (This post was last modified: 11-12-2015 08:59 PM by Vijayram.)
Post: #3
RE: How to select elements with class names
Hi Viscomi,

Thank you very much for the quick reply. I have tried the things that you have mentioned below but no luck. Below are the tried i did...

In my scenario i need to select "Select All" link and click on the done button.
The script for the same is

execAndWait document.querySelector('a[data-ng-click="selectAll()"]').click()
execAndWait class="ds-app-pointer-plain option-vertically-center option-text ng-binding"
execAndWait document.querySelector('a[class="ds-app-pointer-plain option-vertically-center option-text ng-binding"]').click()
execAndWait document.querySelector('a[data-ng-click=selectAll()]').click()

for button id i have the script
clickAndWait id=team-memeber-selection-done

The error i am seeing after the script execute is "Repeat View: Test Data Missing"

How to get out of this error and what is the correct WPT script to click on the Select All
<a class="ds-app-pointer-plain option-vertically-center option-text ng-binding" data-ng-click="selectAll()">Select All</a>

And also i observed some popup in the video but the same is not observed when we executed it manually in the chrome browser. How to handle this type of pop-up issues? Is there any way to clear the browser cache of the the location we are running? Enclosed the scree shot showing the pop up after page loading. The script is as below

1. navigate https://www-qa.adpedge.com/#/prospect - Success
2. setValue name'proxyUsername PMChevUser - Success
3. setValue name'proxyPassword Cdk-0109 - Success
4. clickAndWait name'loginSubmit - Success
5. execAndWait document.querySelector('a[href*="prospect"]').click() - Success
6. execAndWait document.querySelector('a[data-ng-click="selectAll()"]').click() - Failed
7. clickAndWait id=team-memeber-selection-done - Not executed.

For 6th script line our code is "<a class="ds-app-pointer-plain option-vertically-center option-text ng-binding" data-ng-click="selectAll()">Select All</a>"

Could you please look into this and update me where i am going in the wrong way...

Thanks,
Vijay
(11-10-2015 10:14 AM)rviscomi Wrote:  The input to clickAndWait is attribute=value. In your HTML code, there are only two attributes: class and data-ng-click. If there are no other elements with that combination of class names, you could target the Select All element with this pair:

clickAndWait class="ds-app-pointer-plain option-vertically-center option-text ng-binding"

Although I'm not sure if this will work because of the quotes. Omitting them might not work either because of the spaces.

So you can try the second attribute, data-ng-click:

clickAndWait data-ng-click=selectAll()

But again, this might not work because of the parentheses. You'll have to try it to be sure.


If all else fails, you could use querySelector like you attempted. However, clickAndWait only takes an attribute=value pair. So you'll need a different command. execAndWait will take an arbitrary JS statement and execute it. Here's something that might be more robust:

execAndWait document.querySelector('a[data-ng-click="selectAll()"]').click()

All of this would be made so much easier if the element you want to click on had a concise ID. For example if it looked like <a id="select-all" ...>Select All</a> you could simply write:

clickAndWait id=select-all


Attached File(s) Image(s)
   
Find all posts by this user
Quote this message in a reply
11-13-2015, 02:16 AM
Post: #4
RE: How to select elements with class names
The browser profile is completely cleared for each run (cache, cookies, everything).

As far as repeat view goes, if you need an action to run only during first view you can put it inside an if block (scripting page should have an example).
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)