Jump to content

Excel not grabbing ids from spreadsheet and sending them to browser


goku200
 Share

Recommended Posts

I'm having some issues with my script that's not grabbing the id from the cell and appending it to the url test that I have in my script.

Here is my script:

What I'm having issues is looping through the id column in the excel spreadsheet and adding 1 to the url address when its tabbed by using _WD_NewTab. When it goes to the browser I'm wanting it to display: https://127.0.0.1/test.html?id=1 press Enter and save the file as 1.html and so forth for the others. Not sure what I'm doing wrong here. 

 

Edited by goku200
Link to comment
Share on other sites

I see numerous issues with your script --

  • You need to declare the variable $sDesiredCapabilities
  • Your _WD_LoadWait seems out of place. Wouldn't you want it before the initial _WD_FindElement?
  • You load the Excel range into an array named $Array1, then try to access $Array (without the 1)
  • Using Send() is an all around bad idea. Why not use _WD_Navigate?
  • This syntax looks totaling wrong -- clipPut($testLink$aArray1)
  • Et c
Link to comment
Share on other sites

7 minutes ago, Danp2 said:

I see numerous issues with your script --

  • You need to declare the variable $sDesiredCapabilities
  • Your _WD_LoadWait seems out of place. Wouldn't you want it before the initial _WD_FindElement?
  • You load the Excel range into an array named $Array1, then try to access $Array (without the 1)
  • Using Send() is an all around bad idea. Why not use _WD_Navigate?
  • This syntax looks totaling wrong -- clipPut($testLink$aArray1)
  • Et c

I went ahead and made changes to the code. Still am not getting it to copy the id and paste it after

https://127.0.0.1/test.html?id=
Link to comment
Share on other sites

Sounds like you are still using Send. See my earlier response. 😏

Once you address that, then repost your code so that we can take another look.

Some other issues I seem --

  • Instead of this --
Local $aVar[1]
_ArrayAdd ($aVar,_WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@type='submit'][@value='Sign in']"))

_WD_ElementAction($sSession, $aVar[1], 'click')

why not just do this?

Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@type='submit'][@value='Sign in']")
_WD_ElementAction($sSession, $sElement, 'click')
  • This line --
    $aArray1 = ClipGet()

    wipes out the array that you created earlier in your code

  • Not sure that InetGet is going to work in this situation

Link to comment
Share on other sites

You must not be using the full version of Scite. When I use Ctrl+F5 to syntax check your script, this is what I get for output --

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /Prod /AU3check /in "C:\Users\danpollak\Dropbox\webdriver\test3.au3"
+>13:50:29 Starting AutoIt3Wrapper (19.1127.1402.0} from:SciTE.exe (4.2.0.0)  Keyboard:00000409  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\danpollak\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\danpollak\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\danpollak\Dropbox\webdriver\test3.au3
"C:\Users\danpollak\Dropbox\webdriver\test3.au3"(39,29) : warning: $aArray: possibly used before declaration.
For $i = 0 To UBound($aArray)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\danpollak\Dropbox\webdriver\test3.au3"(47,70) : error: FileWrite() [built-in] called with wrong number of args.
    FileWrite("C:\Users\<username>\Downloads\Test" & $aArray1+".html")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\danpollak\Dropbox\webdriver\test3.au3"(39,29) : error: $aArray: undeclared global variable.
For $i = 0 To UBound($aArray)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\danpollak\Dropbox\webdriver\test3.au3 - 2 error(s), 1 warning(s)
!>13:50:30 AU3Check ended. Press F4 to jump to next error.rc:2
+>13:50:30 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.83

The first issue I already mentioned in an earlier post. The 2nd one should be obvious, especially if you review the help file.

You also have an issue where you are trying to use "+" to concatenate strings.

Edit: Script also won't run because you never actual call SetupChrome :rolleyes:

Edited by Danp2
Link to comment
Share on other sites

On 1/27/2021 at 2:54 PM, Danp2 said:

You must not be using the full version of Scite. When I use Ctrl+F5 to syntax check your script, this is what I get for output --

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /Prod /AU3check /in "C:\Users\danpollak\Dropbox\webdriver\test3.au3"
+>13:50:29 Starting AutoIt3Wrapper (19.1127.1402.0} from:SciTE.exe (4.2.0.0)  Keyboard:00000409  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\danpollak\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\danpollak\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\danpollak\Dropbox\webdriver\test3.au3
"C:\Users\danpollak\Dropbox\webdriver\test3.au3"(39,29) : warning: $aArray: possibly used before declaration.
For $i = 0 To UBound($aArray)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\danpollak\Dropbox\webdriver\test3.au3"(47,70) : error: FileWrite() [built-in] called with wrong number of args.
    FileWrite("C:\Users\<username>\Downloads\Test" & $aArray1+".html")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\danpollak\Dropbox\webdriver\test3.au3"(39,29) : error: $aArray: undeclared global variable.
For $i = 0 To UBound($aArray)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\danpollak\Dropbox\webdriver\test3.au3 - 2 error(s), 1 warning(s)
!>13:50:30 AU3Check ended. Press F4 to jump to next error.rc:2
+>13:50:30 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.83

The first issue I already mentioned in an earlier post. The 2nd one should be obvious, especially if you review the help file.

You also have an issue where you are trying to use "+" to concatenate strings.

Edit: Script also won't run because you never actual call SetupChrome :rolleyes:

 

I was able to figure it out. I created an array variable and looped through the Excel spreadsheet and then was able to paste the values in the browser. Thanks for your help Danp2!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...