0

I'm trying to modify all my VBA automations with selenium. I'm trying to write text inside an html element to be able to display it on the screen.

I wish I could change this item from this:

<span id="__xmlview0--panel1Title-inner" dir="auto"> Ricerca </span >

to this:

<span id="__xmlview0--panel1Title-inner" dir="auto"> PIPPO </span>

using a Selenium command.

I tried using the command:

DRIVER.FindElementById("__xmlview0--panel1Title-inner").SendKeys ("PIPPO")

but it doesn't work and returns this error: Error

Does anyone know how I can fix it?

Grazie

4
  • "returns the error" - what specific error do you get? Commented Sep 8, 2023 at 17:50
  • stackoverflow.com/questions/35922259/… Commented Sep 8, 2023 at 17:51
  • Hi, thanks for the reply. I uploaded the photo Commented Sep 11, 2023 at 8:04
  • Did you try the approach shown in the link I posted? Commented Sep 11, 2023 at 15:47

1 Answer 1

0

Try this:

Sample slice code, if is a select mode:

        For x = 1 To 653
            If ch.IsElementPresent(FindBy.XPath("//*[@id='nl" & x & "']")) Then 'verifica se elemento x existe de fato
            ''''Debug.Print ch.FindElementByXPath("//*[@id='nl" & x & "']").Text
                If (ch.FindElementByXPath("//*[@id='nl" & x & "']").Text) <> "" Then 'verifica se elemento x não é vazio
                    If VBA.Trim(ch.FindElementByXPath("//*[@id='nl" & x & "']").Text) = VBA.Trim(ShMacro.Range(RngSubsidaria).Value) Then
                        ch.FindElementByXPath("//*[@id='nl" & x & "']").Click
                        ShMacro.Range(RngCodSubsidaria).Value = x
                    End If
                End If
            End If
        Next x

if is insert text, OK, you code is good, but i use 'FindBy.XPath' on element >inspect > rigth click > Copy > Copy Full Xpath and insert into (FindBy.XPath(" _ here your Full Xpath_ ")) where is " in xpath, change to simple ' only.

Sample my insert:

ch.FindElement(FindBy.XPath("//*[@id='Transaction_TRANDATEfrom']")).SendKeys ShMacro.Range(RngDataDe).Value
Sign up to request clarification or add additional context in comments.

2 Comments

Hi friend, thanks for the reply. I tried your solution with XPath but it doesn't work
Try no use () after sendkey comando use only sendkey "PIPPO"

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.