I am pretty new to VBA. I'm trying to scroll to the bottom of a web page. Below is contents of web page.
<DIV id="Table">
<div style="width: 18px; overflow: auto; height: 912px;" onscroll="Grids[0].Scrolled();" onmousemove="Grids[0].ARow=null;Grids[0].ASec=-1;"><div style="width: 1px; overflow: hidden; height: 1954px;"> </div></div>'
This is VBA Code I have so far.
Dim selector As String
selector = "#Table div[style*='onmousemove']"
Dim rightWindowDiv As HTMLDivElement
Set rightWindowDiv = htmldoc.querySelector(selector)
rightWindowDiv.ScrollTop = rightWindowDiv.ScrollHeight
Somehow it does not work. Can someone help?
Related
When I use this code on forums the top image(background) always shifts left instead of staying centered. The bottom image(floating text) works as is.
<div style="background-image: url('https://i.ibb.co/TmkSL8m/bg7.jpg'); color: #000000; background-color: #000000; background-attachment: fixed; text-align: center;"><img src="https://i.ibb.co/L6zQY0S/name96.png" /></div>
tried setting the width to auto but it locks the background image in place and doesn't allow the text to float over it.
Is there a way to fix the vertical layout of the PagerSettings when displayed at the bottom of a grid?
UPDATE: I am working on build 19.110.0013
I am trying to add numbers to the bottom of a grid using the PagerSettings tag described in the post Add page numbers to the bottom of Process Shipments grid. When I set the PagerVisible to bottom the numbers display vertical, but if I set the PagerVisible to top the numbers are properly displayed as horizontal.
<ActionBar PagerVisible="Bottom" DefaultAction="cmdItemDetails">
<PagerSettings Mode="Numeric" LinksCount="5" />
</ActionBar>
I could not reproduce that behavior in Acumatica version 19.106.0020 so I manually tweaked the CSS in order to reproduce that glitch.
Setting 'display: block' CSS property on GridPagerLink CSS class reproduces the same rendering.
In file '\App_Themes\Default\00_Controls.css' it is set as 'display: inline-block;'.
Inline option will make them stack horizontally so I don't have this glitch on my side.
Which exact Acumatica version are you running?
Use browser HTML inspect element feature to inspect the GridPagerLink.
Does it look like the default style below?
.GridPagerLink {
display: inline-block;
color: RGBA(0, 0, 0, 0.87);
text-decoration: none;
font-size: 15px;
font-weight: bold;
padding: 5px 10px;
height: 18px;
border: solid 1px transparent;
}
The checkbox I am trying to add a tick to is part of an online table and doesn't seem to be coded as a checkbox.
I have tried the following to add a tick and none work:
IE.Document.getElementByID("gridcolumn-1658-titleEl").Click
IE.Document.getElementByID("gridcolumn-1658-textEl").Click
IE.Document.getElementsByClassName("x-column-header-inner x-column-header-over")(0).Click
IE.Document.getElementsByClassName("x-column-header-inner")(0).Click
When I inspect the element, I get to the following, but none of this looks anything like a checkbox (the third one is the actual reference):
<div class="x-column-header x-column-header-checkbox x-column-header-align-left x-box-item x-column-header-default x-unselectable x-column-header-first" style="border-width: 1px; width: 24px; right: auto; left: 0px; top: 0px; margin: 0px; height: 24px;" id="gridcolumn-1658"><div id="gridcolumn-1658-titleEl" class="x-column-header-inner" style="padding-top: 6px; padding-bottom: 6px;"><span id="gridcolumn-1658-textEl" class="x-column-header-text"> </span></div></div>
<div id="gridcolumn-1658-titleEl" class="x-column-header-inner" style="padding-top: 6px; padding-bottom: 6px;"><span id="gridcolumn-1658-textEl" class="x-column-header-text"> </span></div>
<span id="gridcolumn-1658-textEl" class="x-column-header-text"> </span>
The website is OptimoRoute, which can be accessed fairly quickly using a new log in, for those interested!
The button I am trying to click is the top one in the table.
Please refer to the following sample code:
Sub main()
'we define the essential variables
Dim IE As Object, Data As Object
Dim ticket As String
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.navigate ("https://dillion132.github.io/vbacheckbox.html")
While IE.ReadyState <> 4
DoEvents
Wend
Set Data = IE.Document.getElementsByClassName("check")
Debug.Print Data.Length
If Len(Data) > 0 Then
For Each ee In Data
'Debug.Print ee.Value
'Based on the checkbox value to check/uncheck the checkbox.
If ee.Value = "Cat" Then
ee.Checked = True
End If
'check whether the checkbox is checked, then, get the checked value.
If ee.Checked Then
Debug.Print ee.Value & " is checked"
End If
Next ee
End If
End With
Set IE = Nothing
End Sub
Code in the website:
<input class="check" type="checkbox" value="Cat"> Cat </input>
<br />
<input class="check" type="checkbox" value="Dog" >Dog</input>
<br />
<input class="check" type="checkbox" value="Pig" checked ="checked" >Pig</input>
The result as below:
I'm looking to sort a webpage from low price to high price by using the built-in product sort
I am able to successfully select the correct dropdown menu using xpath as follows:
WebDriverWait(driver, 5).until(
EC.element_to_be_clickable((By.XPATH,
'//*[#id="react-views-container"]/div/div/div/div[1]/div/div/div/div[2]/div[1]/div/div[2]/div/div[1]/button')))
This was intended only to be a test of sorts, as I am still relatively new to selenium. However, given this worked I cannot understand why the following does not:
WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((By.XPATH,
'//*[#id="react-views-container"]/div/div/div/div[1]/div/div/div/div[1]/div/div[1]/div/div[2]/div/div/div/div/div[4]')))
This results in an error whereby the timeout is reached. It is not an issue of the timeout being too short. I have tried the div search for the given text, but that also did not work. Here is one example of the search I tried which was nearly copied from a similar question:
Select(driver.find_element_by_xpath("//div[contains(text(), 'Unit Price: Low First')]"))
Here is the HTML for the desired menu item:
<div role="menuitem" tabindex="0" data-radium="true" style="background-color: rgb(247, 247, 247); padding: 8px 16px; font-size: 16px; font-weight: normal; color: white; white-space: nowrap; line-height: 20px; min-width: 260px; height: 36px; cursor: pointer;">
<div data-radium="true" style="float: left; display: block; line-height: 24px;">Unit Price: Low First</div>
</div>
Ok so that was a bit of a painful lesson in html and Selenium. Anyway, I figured it out by creating a list of all the menu items and then iterating through that list and clicking on the one I wanted. At the moment, I have this:
menu_items=driver.find_elements_by_xpath('//div[#role="menuitem"]')
for i in menu_items:
if "Unit Price" in i.text:
i.click()
break
For some reason I cannot just do menu_items[4].click(), but I believe it is due to the elements list being a list of tuples or something, though I will have to check the documentation to verify this. I will update the answer afterwards.
The below values represent a combobox / combo-list on a website. I am trying to select item #3 from the drop down using VBA. I have tried several things, but I have had no luck selecting said item. I have tried looking for solutions on Google and the Stack but haven't found anything that seems to work.
<DIV id=ext-gen256 class="x-layer x-combo-list x-combo-list-small" style="FONT-SIZE: 10px; HEIGHT: 92px; WIDTH: 113px; POSITION: absolute; LEFT: 744px; Z-INDEX: 12007; TOP: 235px; VISIBILITY: visible">
<DIV id=ext-gen257 class=x-combo-list-inner style="HEIGHT: 90px; WIDTH: 111px">
<DIV class="x-combo-list-item" _nodup="30829" viewIndex="0">Select</DIV>
<DIV class="x-combo-list-item" _nodup="30829" viewIndex="1">Item 1</DIV>
<DIV class="x-combo-list-item" _nodup="30829" viewIndex="2">Item 2</DIV>
<DIV class=""x-combo-list-item" _nodup="30829" viewIndex="3">Item 3</DIV>
<DIV class="x-combo-list-item" _nodup="30829" viewIndex="4">Item 4</DIV></DIV></DIV>
I have used several variatons of the below code to try and select the item in question (i.e item #3), but keep getting a runtime error
Dim inputE As MSHTML.HTMLHtmlElement
Set inputE = IE.document.getElementsByClassName("x-combo-list-item")
If inputE.innerText = "Item 3" Then
inputE.Select
End If
This doesn't seem to work. Any help is greatly appreciated. Thanks!