Hi Team, can you send anyone Invoke code for Browser Zoom size 67%

Hi team,

I’m working on E -commerce application in that I need to Invoke the C# code for Browser Zoom size as 67%

I’m using this code

// Create a UiPath browser activity with Invoke Code and use the following code

// Inject JavaScript to change the zoom level
string jsZoomScript = “document.body.style.zoom=‘67%’”;

// Use UiPath’s Inject JS Script activity or invoke JavaScript directly
UiPath.Core.Activities.InjectJsScript injectScript = new UiPath.Core.Activities.InjectJsScript
{
ScriptCode = jsZoomScript,
Browser = browser, // Replace with your browser variable
InjectType = UiPath.Core.Activities.InjectJsScript.JsInjectType.Page
};

// Execute the activity
invokeCodeActivity.Execute(injectScript);

but it’s not working. it returning the below error messages


NewActivity.xaml: No compiled code to run
error CS0117: ‘InjectJsScript’ does not contain a definition for ‘Browser’ At line 9
error CS0103: The name ‘browser’ does not exist in the current context At line 9
error CS0117: ‘InjectJsScript’ does not contain a definition for ‘InjectType’ At line 10
error CS0117: ‘InjectJsScript’ does not contain a definition for ‘JsInjectType’ At line 10
error CS0103: The name ‘invokeCodeActivity’ does not exist in the current context At line 14

Can you anyone help me this code.

it’s really helpful to me.

Regards,
Saikrishna

@Mada_Sai_Krishna

why not use this line in injectjs activity directly?that should suffice the requirement

document.body.style.zoom = "67%";

cheers

@Anil_G

can you tell me how can use that or could you please share Xaml file.

please find the attached screenshots for your reference.


Thanks,
Sai

@Mada_Sai_Krishna

What you did is correct…only thing is to escape double quotes with extra double quotes so use like this ""67%"" and run

cheers

@Anil_G

still same issue


@Mada_Sai_Krishna

can you delete all newlines and have in one line

"function (element, input) {document.body.style.zoom = ""67%"";}"

cheers