I think it is a stupid question to ask in an interview, because it asks a very specific detail of how to use WebDriver that I have not really thought about in the 10 years I am using Selenium, but this might a great answer:
I don't know, but I could try and see what happens. Why do you ask? Did you have problems with this in the past?
I have just tried ...
Hi size() returns integer and you are comparing with string
You can use the size() method of java. util. ArrayList to find the
length or size of ArrayList in Java. The size() method returns an
integer equal to a number of elements present in the array list.
So the ...
This question is about WebDriver W3C specification. As per the specification any implementation has to follow:
If url is not an absolute URL or is not an absolute URL with fragment or not a local scheme, return error with error code invalid argument.
After a lot of thinking and research, here is the solution I finally came up with:
Download the pdf
Verify the pdf using Java
Verifying the pdf using Java was the easy part (since it was, by default, multi-platform). Here is the website who helped me do so: https://www.mkyong.com/java/pdfbox-how-to-read-pdf-file-in-java/
Downloading the pdf in a ...
If you try to open a URL without http or https (for e.g. driver.get(“www.facebook.com”);), get() method will throw an error “org.openqa.selenium.WebDriverException“.
It will also gives error message as “Cannot navigate to invalid URL”.
The area to cover in code reviews deserves a book chapter if not multiple books. First, let's not forget test automation is no different from other branches of software engineering, so let me quote generic suggestions from Gergely Orosz (emphasis mine):
Good code reviews look at the change itself and how it fits into the
codebase. They will look through ...
As far as I can understand, your issue is to extract version number to use it further in the test. So unless you have some context you could go from in order to build proper and reliable xpath, I would suggest to use following approach:
Extract the tag assuming there is no places where divs have "Version" word:var version = element(by.xpath('//div[contains(....
// means that you look for the elements wherever they are ander the current node of xml tree. In your case you start from // which means that the "current node" is the root node.
Then you specify which element you would like to search. span is just a concrete node name while * is a mask accepting any node name. So in your case //span means "take all nodes ...
Selenium probably is not working properly against this Angular custom element.
WebElement button = driver.findElement(By.cssSelector(".mat-icon"));
However, this is a symptom of a problem: Angular ...
Here is the specification for how a webdriver conform implementation should handle element retrieval https://www.w3.org/TR/webdriver/#xpath. XPath is incredibly slow because every layer of your path is basically a loop over all children within the current scope.
id and css selector leverage the fact that browsers are already really good at using those ...
Use switchTo() window
Use switch window to switch to the window you want, then perform the test on that window.
Windows and Tabs are used interchangeably.
Example from above site of using an iterator to switch window:
driver.findElement(By.id(“id of the link which opens new window”)).click();\
waitForNumberofWindowsToEqual(2);//this method is for wait
These seems to be fundamental WebDriver Python questions, maybe you should think about following an online course first. I like the trail and error approach, but as you can see your questions get downvoted, because they are so basic.
Be sure to check the documentation of the WebDriver Python API: https://selenium.dev/selenium/docs/api/py/index.html
I'll consider XPath. It seems you'd need to use text() as well:
//span[@class="filtervalue" and contains(text(), "Search")]
You don't need to use contains(), you can use just text()=, but it seems to me that the text value might change, so contains() might apply even after the change.
Hi css selector does not support using contained text as a identifier :
you could use xpath to find element using text
In your case , all your css locators are incorrect:
the tag you are using is button and not input, so it should start
There is no attribute called "type" in your given ...
Selecting by visible text is only possible via xpath. That being said you can use the class selectors provided above, or create a more specific one, using the onclick parameter, i.e. :
If you want to stick with text, you need to capture all button elements and iterate a ...
using wildcard selector (*) which means if the class attribute has
this proprety at any place it will find this element or
using caveat selector to find elements starting with "buttondefault"
If you want to click the element, then you have use the button tag:
the xpath for the highlighted '+' sign is
(//div[@class="traveler-selector-room-data target-clone-field"]//button[@class="uitk-step-input-button uitk-step-input-plus"] )
you can just change the number to 2, or 3 to get the other two.
Approach i took:
1) Find the parent element which ...
Actually this question shows the lack of basic research from your side.
Before learning a tool and technology, we should have a clear understanding of why we need it in the first place.
In your case, you are trying to automate the login process for the tradingview webpage.
So first understand what are the manual steps involved and then automate it:
The Trading View website has no login on that url. You could try to visit https://www.tradingview.com/#signin or click the Sign In button first.
If you were not explicitly quitting the driver before and you are not doing that now as well then the change could be because of the change in below two areas
Probably something in the logic of how you start/quit your driver and/or tests.
Probably the change could be in the behavior of the application being tested.
In my experience the issue you are ...
This comes up repeatedly.
My answer is that all the studies I have seen have shown that the difference is trivial in comparison to thew actual UI test suoite run time.
For example when the run time is 5 minutes for a UI test, the fact that one selector approach over another is more efficient is still usually on the order of differences under 1 second.
Open any website and click f12, and click the elements tab:
Now click ctrl+F, you can see a text field where you can search the element using XPath,text or CSS
Now click on some element and then give then type the locators //span, and //* in the text field, see what's happening
'//' means that look for the element from 'Current node'
//span looks ...
You can simply filter out the invalid options from the list:
List<WebElement> items = driver.findElements(options);
List<WebElement> validItems = items.stream()
item -> !(
It looks like you are targeting an element with the name of "Sign Out". However, from the code snippet, there is no element with the name "Sign Out". The name attribute is not on the tag.
If this is the only element with this class, you can try:
Click Element class=mat-menu-item
Or, since it's a link:
Click Element link=Sign Out
You can also try to ...
It seems you are trying to click on the disabled icon. Selenium does not click on the disabled button.
You can wait until the element gets enabled using WebDriverWait.
WebDriverWait wait = new WebDriverWait(driver, 15);
Despite you have chosen Niels answer as correct, I would also suggest a way to work around your issue.
What you're talking about is likely a "basic authentication". The best way to bypass this step is to add Authorization header to HTTP requests which are sent by your browser. To do that you need to set up some proxy which would add mentioned header with ...
Authentication via the URL has been deprecated for a while:
While this may sound like a thunder from clear skies for Chrome users,
it is not. The deprecation “order” comes from RFC 3986: ...
3.2.1. User Information ... Use of the format "user:password" in the userinfo field is deprecated.
I finally found out why this way of verifying pdf wasn't working.
I made the false assumption that every platform (Firefox, Chrome, Edge, Safari, etc...) was displaying pdf the same way. But, this isn't the case.
So, my code was working fine using Selenium + Java because I was also using Firefox driver.
However, new relic synthetics doesn't ...