VBA Selenium - Copy part of element text and paste in another field

adinev

New Member
Joined
Nov 10, 2022
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Hi all ,

I am trying to copy part of an element text and paste it in another element ,in its search box. The element contains a a policy number that i need to check in another system and it looks like this

60.22.9591 / RANDOM VENDOR NAME​

I need to get the numbers before the "/" and remove the dots before pasting . Any help will be appreciated.

Here is what i have so far:
VBA Code:
Dim pause1, pause2, url As String
 
 pause1 = "00:00:08"
 
 pause2 = "00:00:30"

 url = "http://abv/"

Dim driver As New WebDriver

Dim rowc, cc, columnC As Integer

Dim tblent As Variant

Dim By As selenium.By

Set By = New selenium.By

driver.Get url

Application.Wait Now + TimeValue(pause1)

driver.FindElementByXPath("/html/body/div[2]/div[1]/ul/li[5]/ul/li[4]/a/span").SendKeys "c"

driver.Get url2

driver.FindElementByXPath("/html/body/l/li[5]/ul/li[4]/a/span").SendKeys "v"

Application.Wait Now + TimeValue(pause1)

driver.FindElementByXPath("/html/body/l/li[5]/ul/li[4]/a/box").Click

Application.Wait Now + TimeValue(pause1)
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
VBA Code:
Sub CleanPolicy()
    Dim pol As String: pol = "60.22.9591 / RANDOM VENDOR NAME"
    pol = Replace(Trim(Left(pol, InStr(1, pol, "/") - 1)), ".", "")
    MsgBox pol
End Sub
 
Upvote 0
VBA Code:
Sub CleanPolicy()
    Dim pol As String: pol = "60.22.9591 / RANDOM VENDOR NAME"
    pol = Replace(Trim(Left(pol, InStr(1, pol, "/") - 1)), ".", "")
    MsgBox pol
End Sub
Hi iggy. Do you have any idea how to solve the first part of the task . I realized, I phrased the question incorrectly so it seems that I am having issues only with the converting of the policy number. Thanks.
 
Upvote 0

Forum statistics

Threads
1,223,876
Messages
6,175,123
Members
452,614
Latest member
MRSWIN2709

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top