1

I am trying to execute Javascript in order to click an element in VBA. The element is in a web app that only runs in IE explorer. I am currently interacting with the element using the Selenium Type library with the following code :

FindElementByXPath("//*[contains(text(), 'Revenue Report')]"

I am able to click the element successfully, but nothing actually happens when I do.

I can easily accomplish what I need to using WebDriver (java) with the following code:

JavascriptLibrary jsLib = new JavascriptLibrary();

WebElement ele2 = driver.findElement(By.xpath("//*[contains(text(), 'Revenue Report')]"));

jsLib.callEmbeddedSelenium(driver, "triggerMouseEventAt", ele2, "click", "0,0");

I have used the "Execute Script" method in the Selenium Type library successfully in the past by using the following:

ExcuteScript("document.getElementByID("element").click();")

but I don't know how to make it work using xpath. Any help would be greatly appreciated.

The following is some source code I used to locate the element:

<TR targetURL="/Bafaefice/TTTaefaeTT/TaefTTT/Rev/RevInput_Page1.asp?HelpURL=/WebHelp/NonMaaefnager/Sign_Onto_Back_Office.htm?Revenue_Report.htm&amp;ScreenID=RVN-002&amp;ScreenName=Revenue Report&amp;ResourceID=397600022" targetFrame="ApaefaefplicatifaonFrame" screenName="Revenue Report" screenID="RVN-002" matraApp="true"><TD class=popupMenuCell noWrap>Revenue Report</TD></TR>

<TD class=popMenCe noWrap>Revenue Report</TD>

1 Answer 1

1

You should try as below :-

 ExcuteScript("arguments[0].click();",ele2)

Where ele2 uses as already found element located by Xpath

Sign up to request clarification or add additional context in comments.

1 Comment

I had to set the "arguments[0]" portion as a string variable first, but otherwise it worked perfectly. Thanks for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.