Selenium VBA runs fine with step F8 but skips a line when running in full F5 [duplicate]










1
















This question already has an answer here:



  • Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click

    5 answers



  • Element MyElement is not clickable at point (x, y)… Other element would receive the click

    2 answers



I searched all over the internet and in this forum and can't find the answer. Below code is used to upload file to a wordpress website. When I use F8 to step through it, it works fine. However, when run the full code, after the upload using XPath ("//input[starts-with(id, 'htm15_')]").SendKeys (ws.Cells(1.4)), the macro seems to skip the next line which is to click on a button (Insert file URL) and the browser stucks on this uploading page and will not load the next page where the Publish button appears. At this point, an error came out and stated couldn't find the element Publish.



I try different things, adding global ImplicitWait, adding timeouts for the above mentioned lines of code and to no avail. It seems that after uploading the file, the macro just doesn't click the button (skips that line of code) and therefore couldn't find the Publish button in the next line. The problem lines of code have been indicated by 2 asterisks. Appreciate any help.



The Error Message



Public Sub UploadPost()

Dim ws As Worksheet
Dim filename As String
Dim wb As Workbook
Dim D As WebDriver
Dim Path As String
Dim i As Integer

Set ws = ThisWorkbook.Worksheets("Data")
Set D = New ChromeDriver
Const URL = "https://www.myweb.com/login/"

'To login to website

With D
.Timeouts.ImplicitWait = 10000 'global implicit wait 5 seconds than default 3 seconds
.Start "Chrome"
.Window.Maximize
.Get URL
.FindElementById("user_login").SendKeys("id").Click
.FindElementById("user_pass").SendKeys("pw").Click
.FindElementByName("submit").Click

End With

'Upload daily file to Download Monitor and get file ID

ws.Range("H2:H9").Clear
D.FindElementById("menu-posts-dlm_download").Click 'Click Download on left menu

For i = 2 To 9

With D

.FindElementByClass("page-title-action").Click 'Click Add New
.FindElementById("title").SendKeys(ws.Cells(i, 2)).Click 'Type title copy from spreadsheet
.FindElementById("_members_only").Click 'Click members only category
.FindElementById(ws.Cells(i, 3)).Click '17-china, 21-HK, 25-NAS, 10-NYSE
.FindElementByLinkText("Add file").Click 'Add File
.FindElementByXPath("//input[starts-with(@id,'dp')]").Clear 'Select the correct date
.FindElementByXPath("//input[starts-with(@id,'dp')]").SendKeys (ws.Cells(i, 9))
.FindElementByLinkText("Upload file").Click
.FindElementByLinkText("Upload Files").Click
.FindElementByXPath("//input[starts-with(@id,'html5_')]").SendKeys (ws.Cells(i, 4)) 'upload file using path from spreadsheet
**.FindElementByXPath("//*[@id='__wp-uploader-id-0']/div[5]/div/div[2]/button").Click 'Click save Insert file URL
.FindElementById("publish").Click**
ws.Cells(i, 8) = D.FindElementByXPath("//*[@id='dlm-info-url']").Value


End With

Next i









share|improve this question















marked as duplicate by DebanjanB selenium
Users with the  selenium badge can single-handedly close selenium questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 14 '18 at 7:21


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • I have reviewed the posts you have linked here and tried to adjust my code but couldn't resolve it. It is because I can't find the same commands in those posts such as .wait.until elementobeclickable etc. as I'm using selenium basic type library in VBA. Any help in putting together the right command for selenium basic vba is greatly appreciated.

    – sKhan
    Nov 14 '18 at 19:19











  • My code is working now. I inserted a .wait (5000) after the upload code and before clicking the button code and now it's running good. Thanks!

    – sKhan
    Nov 14 '18 at 21:23















1
















This question already has an answer here:



  • Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click

    5 answers



  • Element MyElement is not clickable at point (x, y)… Other element would receive the click

    2 answers



I searched all over the internet and in this forum and can't find the answer. Below code is used to upload file to a wordpress website. When I use F8 to step through it, it works fine. However, when run the full code, after the upload using XPath ("//input[starts-with(id, 'htm15_')]").SendKeys (ws.Cells(1.4)), the macro seems to skip the next line which is to click on a button (Insert file URL) and the browser stucks on this uploading page and will not load the next page where the Publish button appears. At this point, an error came out and stated couldn't find the element Publish.



I try different things, adding global ImplicitWait, adding timeouts for the above mentioned lines of code and to no avail. It seems that after uploading the file, the macro just doesn't click the button (skips that line of code) and therefore couldn't find the Publish button in the next line. The problem lines of code have been indicated by 2 asterisks. Appreciate any help.



The Error Message



Public Sub UploadPost()

Dim ws As Worksheet
Dim filename As String
Dim wb As Workbook
Dim D As WebDriver
Dim Path As String
Dim i As Integer

Set ws = ThisWorkbook.Worksheets("Data")
Set D = New ChromeDriver
Const URL = "https://www.myweb.com/login/"

'To login to website

With D
.Timeouts.ImplicitWait = 10000 'global implicit wait 5 seconds than default 3 seconds
.Start "Chrome"
.Window.Maximize
.Get URL
.FindElementById("user_login").SendKeys("id").Click
.FindElementById("user_pass").SendKeys("pw").Click
.FindElementByName("submit").Click

End With

'Upload daily file to Download Monitor and get file ID

ws.Range("H2:H9").Clear
D.FindElementById("menu-posts-dlm_download").Click 'Click Download on left menu

For i = 2 To 9

With D

.FindElementByClass("page-title-action").Click 'Click Add New
.FindElementById("title").SendKeys(ws.Cells(i, 2)).Click 'Type title copy from spreadsheet
.FindElementById("_members_only").Click 'Click members only category
.FindElementById(ws.Cells(i, 3)).Click '17-china, 21-HK, 25-NAS, 10-NYSE
.FindElementByLinkText("Add file").Click 'Add File
.FindElementByXPath("//input[starts-with(@id,'dp')]").Clear 'Select the correct date
.FindElementByXPath("//input[starts-with(@id,'dp')]").SendKeys (ws.Cells(i, 9))
.FindElementByLinkText("Upload file").Click
.FindElementByLinkText("Upload Files").Click
.FindElementByXPath("//input[starts-with(@id,'html5_')]").SendKeys (ws.Cells(i, 4)) 'upload file using path from spreadsheet
**.FindElementByXPath("//*[@id='__wp-uploader-id-0']/div[5]/div/div[2]/button").Click 'Click save Insert file URL
.FindElementById("publish").Click**
ws.Cells(i, 8) = D.FindElementByXPath("//*[@id='dlm-info-url']").Value


End With

Next i









share|improve this question















marked as duplicate by DebanjanB selenium
Users with the  selenium badge can single-handedly close selenium questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 14 '18 at 7:21


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • I have reviewed the posts you have linked here and tried to adjust my code but couldn't resolve it. It is because I can't find the same commands in those posts such as .wait.until elementobeclickable etc. as I'm using selenium basic type library in VBA. Any help in putting together the right command for selenium basic vba is greatly appreciated.

    – sKhan
    Nov 14 '18 at 19:19











  • My code is working now. I inserted a .wait (5000) after the upload code and before clicking the button code and now it's running good. Thanks!

    – sKhan
    Nov 14 '18 at 21:23













1












1








1









This question already has an answer here:



  • Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click

    5 answers



  • Element MyElement is not clickable at point (x, y)… Other element would receive the click

    2 answers



I searched all over the internet and in this forum and can't find the answer. Below code is used to upload file to a wordpress website. When I use F8 to step through it, it works fine. However, when run the full code, after the upload using XPath ("//input[starts-with(id, 'htm15_')]").SendKeys (ws.Cells(1.4)), the macro seems to skip the next line which is to click on a button (Insert file URL) and the browser stucks on this uploading page and will not load the next page where the Publish button appears. At this point, an error came out and stated couldn't find the element Publish.



I try different things, adding global ImplicitWait, adding timeouts for the above mentioned lines of code and to no avail. It seems that after uploading the file, the macro just doesn't click the button (skips that line of code) and therefore couldn't find the Publish button in the next line. The problem lines of code have been indicated by 2 asterisks. Appreciate any help.



The Error Message



Public Sub UploadPost()

Dim ws As Worksheet
Dim filename As String
Dim wb As Workbook
Dim D As WebDriver
Dim Path As String
Dim i As Integer

Set ws = ThisWorkbook.Worksheets("Data")
Set D = New ChromeDriver
Const URL = "https://www.myweb.com/login/"

'To login to website

With D
.Timeouts.ImplicitWait = 10000 'global implicit wait 5 seconds than default 3 seconds
.Start "Chrome"
.Window.Maximize
.Get URL
.FindElementById("user_login").SendKeys("id").Click
.FindElementById("user_pass").SendKeys("pw").Click
.FindElementByName("submit").Click

End With

'Upload daily file to Download Monitor and get file ID

ws.Range("H2:H9").Clear
D.FindElementById("menu-posts-dlm_download").Click 'Click Download on left menu

For i = 2 To 9

With D

.FindElementByClass("page-title-action").Click 'Click Add New
.FindElementById("title").SendKeys(ws.Cells(i, 2)).Click 'Type title copy from spreadsheet
.FindElementById("_members_only").Click 'Click members only category
.FindElementById(ws.Cells(i, 3)).Click '17-china, 21-HK, 25-NAS, 10-NYSE
.FindElementByLinkText("Add file").Click 'Add File
.FindElementByXPath("//input[starts-with(@id,'dp')]").Clear 'Select the correct date
.FindElementByXPath("//input[starts-with(@id,'dp')]").SendKeys (ws.Cells(i, 9))
.FindElementByLinkText("Upload file").Click
.FindElementByLinkText("Upload Files").Click
.FindElementByXPath("//input[starts-with(@id,'html5_')]").SendKeys (ws.Cells(i, 4)) 'upload file using path from spreadsheet
**.FindElementByXPath("//*[@id='__wp-uploader-id-0']/div[5]/div/div[2]/button").Click 'Click save Insert file URL
.FindElementById("publish").Click**
ws.Cells(i, 8) = D.FindElementByXPath("//*[@id='dlm-info-url']").Value


End With

Next i









share|improve this question

















This question already has an answer here:



  • Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click

    5 answers



  • Element MyElement is not clickable at point (x, y)… Other element would receive the click

    2 answers



I searched all over the internet and in this forum and can't find the answer. Below code is used to upload file to a wordpress website. When I use F8 to step through it, it works fine. However, when run the full code, after the upload using XPath ("//input[starts-with(id, 'htm15_')]").SendKeys (ws.Cells(1.4)), the macro seems to skip the next line which is to click on a button (Insert file URL) and the browser stucks on this uploading page and will not load the next page where the Publish button appears. At this point, an error came out and stated couldn't find the element Publish.



I try different things, adding global ImplicitWait, adding timeouts for the above mentioned lines of code and to no avail. It seems that after uploading the file, the macro just doesn't click the button (skips that line of code) and therefore couldn't find the Publish button in the next line. The problem lines of code have been indicated by 2 asterisks. Appreciate any help.



The Error Message



Public Sub UploadPost()

Dim ws As Worksheet
Dim filename As String
Dim wb As Workbook
Dim D As WebDriver
Dim Path As String
Dim i As Integer

Set ws = ThisWorkbook.Worksheets("Data")
Set D = New ChromeDriver
Const URL = "https://www.myweb.com/login/"

'To login to website

With D
.Timeouts.ImplicitWait = 10000 'global implicit wait 5 seconds than default 3 seconds
.Start "Chrome"
.Window.Maximize
.Get URL
.FindElementById("user_login").SendKeys("id").Click
.FindElementById("user_pass").SendKeys("pw").Click
.FindElementByName("submit").Click

End With

'Upload daily file to Download Monitor and get file ID

ws.Range("H2:H9").Clear
D.FindElementById("menu-posts-dlm_download").Click 'Click Download on left menu

For i = 2 To 9

With D

.FindElementByClass("page-title-action").Click 'Click Add New
.FindElementById("title").SendKeys(ws.Cells(i, 2)).Click 'Type title copy from spreadsheet
.FindElementById("_members_only").Click 'Click members only category
.FindElementById(ws.Cells(i, 3)).Click '17-china, 21-HK, 25-NAS, 10-NYSE
.FindElementByLinkText("Add file").Click 'Add File
.FindElementByXPath("//input[starts-with(@id,'dp')]").Clear 'Select the correct date
.FindElementByXPath("//input[starts-with(@id,'dp')]").SendKeys (ws.Cells(i, 9))
.FindElementByLinkText("Upload file").Click
.FindElementByLinkText("Upload Files").Click
.FindElementByXPath("//input[starts-with(@id,'html5_')]").SendKeys (ws.Cells(i, 4)) 'upload file using path from spreadsheet
**.FindElementByXPath("//*[@id='__wp-uploader-id-0']/div[5]/div/div[2]/button").Click 'Click save Insert file URL
.FindElementById("publish").Click**
ws.Cells(i, 8) = D.FindElementByXPath("//*[@id='dlm-info-url']").Value


End With

Next i




This question already has an answer here:



  • Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click

    5 answers



  • Element MyElement is not clickable at point (x, y)… Other element would receive the click

    2 answers







excel vba selenium selenium-webdriver selenium-chromedriver






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 7:59









Pᴇʜ

21.4k42750




21.4k42750










asked Nov 13 '18 at 20:10









sKhansKhan

142




142




marked as duplicate by DebanjanB selenium
Users with the  selenium badge can single-handedly close selenium questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 14 '18 at 7:21


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by DebanjanB selenium
Users with the  selenium badge can single-handedly close selenium questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 14 '18 at 7:21


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • I have reviewed the posts you have linked here and tried to adjust my code but couldn't resolve it. It is because I can't find the same commands in those posts such as .wait.until elementobeclickable etc. as I'm using selenium basic type library in VBA. Any help in putting together the right command for selenium basic vba is greatly appreciated.

    – sKhan
    Nov 14 '18 at 19:19











  • My code is working now. I inserted a .wait (5000) after the upload code and before clicking the button code and now it's running good. Thanks!

    – sKhan
    Nov 14 '18 at 21:23

















  • I have reviewed the posts you have linked here and tried to adjust my code but couldn't resolve it. It is because I can't find the same commands in those posts such as .wait.until elementobeclickable etc. as I'm using selenium basic type library in VBA. Any help in putting together the right command for selenium basic vba is greatly appreciated.

    – sKhan
    Nov 14 '18 at 19:19











  • My code is working now. I inserted a .wait (5000) after the upload code and before clicking the button code and now it's running good. Thanks!

    – sKhan
    Nov 14 '18 at 21:23
















I have reviewed the posts you have linked here and tried to adjust my code but couldn't resolve it. It is because I can't find the same commands in those posts such as .wait.until elementobeclickable etc. as I'm using selenium basic type library in VBA. Any help in putting together the right command for selenium basic vba is greatly appreciated.

– sKhan
Nov 14 '18 at 19:19





I have reviewed the posts you have linked here and tried to adjust my code but couldn't resolve it. It is because I can't find the same commands in those posts such as .wait.until elementobeclickable etc. as I'm using selenium basic type library in VBA. Any help in putting together the right command for selenium basic vba is greatly appreciated.

– sKhan
Nov 14 '18 at 19:19













My code is working now. I inserted a .wait (5000) after the upload code and before clicking the button code and now it's running good. Thanks!

– sKhan
Nov 14 '18 at 21:23





My code is working now. I inserted a .wait (5000) after the upload code and before clicking the button code and now it's running good. Thanks!

– sKhan
Nov 14 '18 at 21:23












0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto