cannot find a element by VBA selenium and follow the code - vba

I'm trying to find and element which is a drop down box , select the option and press the view report button() to generate the report but when I'm running my Macro it cannot find the element and I tried different find element method.
could you please help me :
here is the selenium VBA code enter image description here
[website inspect view[][2]2

Related

How can I click a Dropdown menu option in a webpage using VB.NET and Selenium

I am trying to click on Supplier. I've added a screen shot of the source code. In this code sample I have successfully logged into the site, but the next step is to click on that dropdown to get to the next screen. I have hard coded the link and then used GET to call open the URL string. However, it's my understanding that I should be able to do this without hard coding the URL for Supplier. I should be able to pull it with a single line of code versus trying to figure out how to loop through somehow to get to the "Supplier" selection. I am trying to account for the scenario if this link changes so I want my code to pull it directly from the source vs hard coding. I've uploaded a screen shot of the source code. How can I click on supplier?
Dim ch As New Selenium.ChromeDriver
Dim FindBy As New Selenium.By
ch.Get("URL", raise:=False)
ch.SwitchToFrame("MainFrame")
ch.FindElementById("ctl04_txtUsername").SendKeys(Form1.TxtBId.Text)
ch.FindElementById("ctl04_txtPassword").SendKeys(Form1.TxtBPass.Text)
ch.FindElementById("ctl04_btnLogin").ClickDouble
str = "https://am.adech.net/csge/portals/postmodern/desktpdefault.aspx?tabindex=1&tabid=211&sTarget=S"
ch.Get str, Raise:=False
The answer to my question is:
First find the element by ID, find that elements anchor by tag, next getattribute by "href" and then navigate to that anchors "href" link.

How to get the xpath of suggested items of google place auto complete field in selenium

I am doing a selenium project. There is a field called address which is a google place auto complete field that suggests palces name like dropdown. Problem with the field is, it cannot be inspected. Whenever i click on inspection button the suggested auto complete list get disappeard?
How can I automate this?

selenium, hidden button by overlapped input ( not clickable)

Is there any way on how to click a hidden button by an overlapped input text field, for example if you go to www.google.com and enter a text to search for, selenium can not find the "Search Google" button because it is hidden by the autocomplete of the text field.
Thanks.
You can bypass the validation by using #click! instead of #click. Basically, this triggers the click via JavaScript rather than through standard Selenium commands.
browser = Watir::Browser.new
browser.goto('www.google.com')
browser.text_field(name: 'q').set('watir')
browser.button(name: 'btnK').click!
If you are only using Selenium, you can do:
btn = driver.find_element(name: 'btnK')
driver.execute_script('arguments[0].click();', btn)
As discussed in the comments, you could also close the suggestions box before trying to click the button. You can do this by moving focus to any other element - eg the first link on the page. Depending on what you're testing, this may or may not have value.
browser.text_field(name: 'q').set('watir')
browser.link.focus # move focus to any other element so suggestions close
browser.button(name: 'btnK').click

Selenium - element is not visible

I am trying to enter text into a text box and below is the error I get:
An exception of type 'OpenQA.Selenium.ElementNotVisibleException' occurred in WebDriver.dll but was not handled in user code
Additional information: Element is not currently visible and so may not be interacted with
However, this element is interactable and you can enter text into it.
The displayed field for the element is false.
Is there a way to override this an force selenium to enter the text?
Perhaps using javascript? If you have any ideas please let me know.
Many Thanks,
Rahul Dixit
First thing you need to do is execute javascript to enable textbox later you can run your selenium code
for example :
String textbox = "document.getElementsByName('lname')[0].removeAttribute('disabled');";
javascript.executeScript(textbox);
Thread.sleep(3000);

How to assert a button's property

I am using selenium web driver and currently automating a registration form. There are various fields like username,password etc which we have to fill in the details and click on the terms and conditions check box and the account create button gets enabled.
Right now there is some issue with the java script and all my assertions for the create account button is failing. Is there any way I can work on this issue?
possible solution:
apply getAttribute() function to the element you need. And compare data obtained with expected data to be:
WebElement button = driver.findElement(By.xpath(..blablblalb...));
String color= button.getAttribute("color");
//verifyinh that color is that of expected
Assert.assertTrue(color.contains("red"));