Find this element in this website using Selenium - vba

I have used Selenium in VBA to get to this page and would like to click on the 'WIP Management' Button. However the code that I use says the element is not found. Could someone please help.
This is the part of the website with the inspect panel
This is my code that can't find the element.
If obj.IsElementPresent(By.XPath("//button[text()='WIP Management']")) Then
MsgBox "True"
Else
MsgBox "False"
End If

I can not see the button tag in HTML, try the below locator
//*[text()='WIP Management']
OR
//*[contains(text(),'WIP Management')]
OR
//*[normalize-space()='WIP Management']

Related

Access to a pop-up in selenium

I do have the following code to click a Google button that open a pop-up and then it selects the second Item. It worked fine but now is failing, I guess that due to ID name changed. I do not remember how I Inpectioned the pop-up ID since it does not appears in the "Inpection" Chrome Window.
numOpiniones.click()
self.driver.find_element(By.XPATH,"//button[#data-value='Ordenar']").click()
sleep(random.uniform(1, 1.5))
self.driver.find_element(By.XPATH, "//li[#role='menuitemradio' and #data-index='1']").click()
"menuitemradio" does not exists anymore but I can not see that element in the inspector panel when is created/displayed.
enter image description here
You can use the following css path
driver.find_element(By.CSS_SELECTOR, '#hovercard > #action-menu > [data-index="1"]')

Selenium Webscraping - Print element that is not visible on the site but its on Inspect

enter image description here
I'm trying to print this 91040 from the site but I can't seem to do it and I think the reason is that 91040 is not visible on the site but only on inspect.
element = driver.find_element(By.XPATH,'//div[#class="code-container"]//span[2]')
When I paste this XPATH in the find bar on Inspect it locates the item but when I'm trying to print the element nothing gets printed. I tried these options.
print(element)
print(element.text)
So I'm thinking that the problem is that 91040 is not an actual visible text.
For anyone having the same problem I found the answer
hidden_text = element.get_attribute("textContent")

Is there a way to click on anchor link

Please help me as the anchor tag looks like the below
<a title ="excel" class="activelink"style="Text-Decoration: none; onclick="$find('ReportViewerControl').exportReport('Excelopenxml');" href ="javascript:void(0)" alt="Excel" _selected="true"> Excel</a>
This doesn't have any document id or class.. Any help would be highly appreciated.
I try to check your HTML code and found that it contains the class but it can be possible that many other elements on the page using the same class. If you try to access the link using that class then it can possible that you click the incorrect element on the page.
We can see that the link contains the ' Excel' text. We can try to loop through all the links on the page and try to match the innerHTML to find that specific link.
Example:
'Below is code to loop through anchor tags, find the specific link, and click it.
Set elems = IE.document.getElementsByTagName("a")
For Each elem In elems
If (elem.innerHTML) = " Excel" Then
elem.Click
Exit For
End If
Next elem
Output:
In a similar way, you can also match other attributes from the anchor tag that may also help to click the link.
Note: This code example is for clicking the specific link on a page. It may not help you to automate the file download.
Further, you can try to modify the code example as per your own requirements.

VBA Macro - How to click a link in java web page

I want to get data from a web page.
web adress:
https://intvrg.gib.gov.tr/intvrg_side/main.jsp?token=d1078f5e3dc646b78d5d4e5842f21e97feb48d366bc7617458b6679dec12675154a01fccc42292bb04d926bc259dbc75e39dd8e202535fd70a7098396c74a6f7
After this page I click "Diger Sorgulamalar" at the right box, then try to click "Vergi Kimlik Numarası Dogrulama"
With vba code after navigating to the web page I can click first link with the code:
IE.document.getElementById("gen__1155").Click
However, I cannot navigate to the "Vergi Kimlik Numarası Dogrulama". I tried:
IE.document.getElementById("H7d190dfed4bed-faf6170603664e").Click
But this does not work. The web source code is like below.
How can I go to that page?
The issue is that H7d190dfed4bed-faf6170603664e does not appear in the HTML code you posted, so it cannot find it. So probably the ID changes everytime the page is accessed so you cannot hardcode the ID.
You need to find something else to determine the correct link. Is the link name Vergi Kimlik Numarası Dogrulama always the same?
Then you could loop through all links and check to find the name of the tag:
For Each lnk In IE.document.GetElementByTagName("a")
If lnk.innerHTML = "Vergi Kimlik Numarası Dogrulama" Then
lnk.Click
Exit For 'if there is only one link with that name you can exit here.
End If
Next lnk

selenium send key for xpath not working

I want make automation for this web site
in this web site 3 text box are here check image
1st text box x path is /html[1]/body[1]/div[3]/div[1]/div[2]/div[1]/searchbar[1]/div[1]/div[1]/div[1]/div[1]/form[1]/div[1]/div[1]/div[1]/input[1]
here is my code
driver.findElement(By.xpath("/html[1]/body[1]/div[3]/div[1]/div[2]/div[1]/searchbar[1]/div[1]/div[1]/div[1]/div[1]/form[1]/div[1]/div[1]/div[1]/input[1]")).sendKeys("rio salon");
when I run this code I got this error
Exception in thread "main"
org.openqa.selenium.ElementNotInteractableException: Element is not reachable by keyboard
How can i fix it? I hope my xpath is correct.
The field has aria-hidden=true attribute, so you get ElementNotInteractableException. You need to click on the dropdown first to change the attribute to true
WebElement dropdown = driver.findElement(By.xpath("//*[#id='search-form']/div/div[1]/div/div[1]/span"));
dropdown.click();
WebElement textField = dropdown.findElement(By.xpath("./parent::div/following-sibling::input[contains(#class, 'ui-select-search')]"));
textField.sendKeys("rio salon");
You can click in an input field with a div or span tag, but you cannot type in the field. So, your XPath must be written with an input tag if you want to sendkeys or type in an input field. For example:
//input[contains(#placeholder,'Site')]