Can we directly pass a variable in the selector?

Hello

Can we directly pass the variable in the selector?

Like we are saving the selector in the variable below. But what if i want pass the variable in the selector directly.

Example:: Var1 ="<html app='chrome.exe' title='Smart Search | LinkedIn Recruiter' /><webctrl tag='A' css-selector='body&gt;div&gt;div&gt;section&gt;div&gt;section&gt;footer&gt;nav&gt;div&gt;ul&gt;li&gt;a' idx='"+initPCount.ToString+"' />"

Anyone help me?

3 Likes

In which selector are you trying you use the variable. Can you show the selector?

@vishal.kp

Please check above.

Cheers

@AryanSingh Yes you can pass variables in the selectors.

yes definitely you can pass that variable inside the selector. The condition is always the variable type should be in string or generic type. :slight_smile:

1 Like

Try as much as possible to avoid the css in the selectors. They are unstable.

1 Like

yah of course we can pass the variable in the selector
but we need to keep these things in ming
–whenever a variable is passed to a selector it should be like this
attributename like
aaname = ’ " + variablename.ToString + " '
–and if we are passing variable to a selector that change should not be made inside the SELECTOR EDITOR
–instead we need to pass the variable to the selector attribute and copy that whole selector and pass that as a STRING value between double quotes to the SELECTOR property in the property panel of any activity we use
–the reason is sometimes the variable passed with selector inside the SELECTOR EDITOR wont work or it wont take either the variable been passed
–so if we pass that whole selector as a string value to the selector property it would work for sure

hope this would help you
Cheers @AryanSingh

1 Like

@Palaniyappan
@vishal.kp
@indra

So, we need to use the variable in the double quotes in the selector right?

2 Likes

yes exactly
like this
attributename = ’ " + variablename.ToString + " '

Cheers @AryanSingh

1 Like

Not in double quotes . just pass the variable. Its simple as that. when you pass it inside double quotes the variable is converted to string.

1 Like

@Palaniyappan

Ok thanx. Let me try.

Please check your inbox i have one query!

1 Like

oh
i didnt get any buddy
Cheers @AryanSingh

@Palaniyappan

Please check now.

1 Like

yah sure
did this get resolved
Cheers @AryanSingh

1 Like

@Palaniyappan

Will check and tell if resolved.

Great
@AryanSingh

1 Like

@Palaniyappan

Can we use while activity to iterate through all pages and extract the data individually for the page?

hmm yah of course
but we need to mention the page number in selector by passing a variable and make sure that a counter is used and incremented as well
Cheers @AryanSingh

@Palaniyappan

Yeah i am trying to do that but it is not able to do it properly. Repeating same values.

@Palaniyappan

How can i use the data scraping activity to iterate through all the pages?

Can you guide me regarding that?