0

I am developing a VBA where it will open the Fitnesse link to create a new Test page and write Page name, Page content and click save.

  1. Am using InternetExplorerMedium from VBA library to access Fitnesse link to create new Test page(Success).
  2. Then i will read content in an excel sheet into a variable(Success).
  3. Then i will paste the content into the text area of the new Test page created(Not Happening).
  4. Then i will click Save(Success)

Set IE = New InternetExplorerMedium
sURL = "FitnesseURL"
With IE
    .Navigate sURL
    .Visible = True
End With
IE.Document.getElementById("pagename").Value = "Dummay_Page" '--> This is Page name text Box
StrVal = <Content from Sheet1>
IE.Document.getElementById("pageContent").innerText = StrVal '--> This is Page Textarea
Set btn = IE.Document.getElementByName("save") ' -- This is a Page button
btn(0).Click

I want the content from the Sheet1 to be pasted in the Fitnesse Test page textarea but it is not happening i have tried .innerText,.innerHTML and .Value options

QHarr
  • 83,427
  • 12
  • 54
  • 101
Vidhyasaghar
  • 45
  • 1
  • 9
  • Can you share the url? Failing that - the html using the snippet tool via [edit]. – QHarr Jul 17 '19 at 13:12
  • The application is in my enterprise machine, sorry. But the application looks something like [this](https://media.licdn.com/dms/image/C5112AQFY5SssHzI3aA/article-inline_image-shrink_1500_2232/0?e=1567641600&v=beta&t=Ofz1CvFmJM1UXFBFT_JT5ZhBBSnKvGGkvhaYroGkagE) – Vidhyasaghar Jul 17 '19 at 14:13
  • This is caused due to Win 10 i think. Am able to run the same code in Win 7 but not in Win 10 – Vidhyasaghar Aug 02 '19 at 11:13
  • This line Set btn = IE.Document.getElementByName("save") should be Set btn = IE.Document.getElemenstByName("save")(0) – QHarr Aug 02 '19 at 11:15
  • We need to see the html in question however for the rest of the answer, – QHarr Aug 02 '19 at 11:15

1 Answers1

0

Please try to use F12 developer tools to check the html element, make sure it contains the pagename and pageContent elements. Besides, please check your code, you lost a 's' in the getElementsByName method.

If still not working, I suggest you could try to use the following code(create the IE object using CreateObject method, the following code works well on my side.):

Sub test()

Dim IE As Object

Set IE = CreateObject("InternetExplorer.application")

sURL = "website url"

With IE
    .Navigate sURL
    .Visible = True
End With


IE.Document.getElementById("pagename").Value = "Dummay_Page" '--> This is Page name text Box

StrVal = <cocntent from sheet1>

IE.Document.getElementById("pageContent").innerText = StrVal '--> This is Page Textarea

Set btn = IE.Document.getElementsByName("save")(0) '-- This is a Page button

btn.Click

End Sub
Zhi Lv
  • 18,845
  • 1
  • 19
  • 30
  • I have already verified the element names by checking the HTML elements, i wan not able to paste the actual code because the setup is in enterprise machine, hence the missing 's'. And i tried the createObject also and it throws "Method document of object 'Iwebbrowser2' failed" error. Any idea how to resolve that? – Vidhyasaghar Jul 17 '19 at 10:56
  • It seems that you are using internet explorer at a medium integrity level, try to use "Set IE = CreateObject("InternetExplorer.ApplicationMedium")", here is a [thread](https://stackoverflow.com/questions/30086425/excel-vba-method-document-of-object-iwebbrowser2-failed/41471828#41471828), you could refer to it. – Zhi Lv Jul 17 '19 at 11:38
  • I am using InternetExplorerMedium, this is similar to the CreateObject("InternetExplorer.ApplicationMedium") right?. – Vidhyasaghar Jul 17 '19 at 13:50
  • Yes, you could have a try. – Zhi Lv Jul 18 '19 at 07:49
  • That's what i already did but it did not write data into the Textarea. Is it because since the Textarea is inside a set of forms like(Body->Article->Form->Fieldset->TextArea)? I tried to create a dummy webpage with only one textarea and applied the same code and it executed fine – Vidhyasaghar Jul 18 '19 at 08:55
  • I have tested it (try to put the Textarea inside the forms), it still works well on my side, perhaps there have another part of code prevent this behavior. can you post the Enough code to reproduce the problem as in [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve), so that we could test it. – Zhi Lv Jul 18 '19 at 09:15