Where is right-click menu in Chrome v99? - java

Tried to find xPath of an element in the latest Chrome (v99). It looks like the right-click menu in Chrome's "inspect" pane is not available. How does one find the xPath of elements for Selenium automation?

Chrome's Inspect menu item is still available after the right-click.
However, google-chrome latest version is Version 100.x which you need to upgrade to.
Having said that, some websites may disable the right-click for security or some other reasons. In those cases you have use the google-chrome-devtools to identify the desired elements.
You can find a relevant detailed discussion in How to inspect element for Selenium v3.6 as FireBug is not an option any more for FF 56?

Related

I am trying to access secure website where right button click is disabled. by using selenium Xpath cannot click on elements

The website which for which I am trying to do automation is a secure website where some functions like right clicking have been disabled. I am using the exact xpath for the login input field but it is not working. My Xpath is as follows:
driver.findElement(By.xpath("//input[contains(#class,'input')]")).sendKeys("Aa12");
SeeTest provides a way for opening the developer tools even in such cases.
They also have different versions of chrome in which you can try your scenario.
Their documentation might help you more on this.

Selenium Automation on IE11 (Enterprise mode)

I have installed Enterprise mode on IE11 to support applications which are only run on lower version of IE.
Using Enterprise mode on, to support application adhered to IE10 only I started scripting.
I am successfully able to traverse few pages but at one particular sidebar I am not able to click element.
It gets highlighted using javascript which means I find the element. But I am not able to click the element. it gets dotted square around the element.
I don't get any exception on that line.
There are no frames issue.
P.S: One of the post stated that there might be an issue with unexceptional behaviour of Tomcat. Due to which I find element but click() event does not work.
Try:
element.sendKeys(Keys.ENTER);
If not working try:
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);

Finding Elements in a Redrawn DOM

We have a website which has a wijmo grid in it. I am attempting to test this website. In IE the grid is drawn, yet when I go into the "Developer Tools", the grid is not actually there. This makes running Selenium tests very difficult as Selenium cannot find it either.
Has anyone run into this before? If so, how do I successfully run my tests?
The grid will be part of the DOM and you should be able to select it successfully with the correct path using Selenium.
I believe it is the tools that are misleading and are simply not updating when the DOM changes.
I would try checking another browser, for example Google Chrome (F12 in Windows). In my experience the IE Developer Tools are not as powerful or feature rich as the Chrome tools. The Chrome tools do update the DOM when elements are manipulated.
It looks like it is working now. The Developer had a pre-loader which was causing the problem. Once that was disabled it is now able to find the elements.

WebDriver unable to locate element (link/Java)

I'm using Selenium to navigate a webpage which has a link called "Mail", using WebDriver (just recently switched from RC to WebDriver). I want to click on the link but the testcase always fails with the error:
org.openqa.selenium.NoSuchElementException: Unable to locate element:
{"method":"link text","selector":"Mail"}
When inspecting the element with Firebug I get the following HTML:
Mail
This is the Java which attempts to click the link:
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.findElement(By.linkText("Mail"));
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
I can see that the element is present on screen but still, the test case fails.
Does anyone know what I might be missing here or an alternative way to find the link element?
Try via XPath. Example:
driver.findElement(By.xPath("/a[text()='Mail']"));
Would also be worthwhile double checking to ensure there are no iframes on the page.
Even i had faced this situation once. View your source code and find out if the element you are looking for is inside a frame. If yes, first switch to the frame in which the element is located and then look out for the element. It worked this way for me.
So far the best workaround I found for cases like this:
Open Firefox with Selenium IDE installed
In firefox open the test page
Run selenium IDE, start recording and click the link
Selenium IDE will offer you ways how to locate the target. If you switch to relative XPath, it should do the magic (Or, in my cases, it always helped)

How to use Xpath of button in Selenium RC?

I am working in Selenium RC. Can anyone please let me know how to write xpath for button in Selenium (Java)?
You should develop the script in the Selenium IDE (download) before porting it to Selenium RC. In Selenium IDE, when you click anything on the webpage, it should automatically generate some kind of selector for the element you clicked. Then, once you've recorded all the events, you Format it in whatever language you're using, and then you copy and paste it to your Selenium RC code.
But the Recorder Javascript isn't foolproof (e.g. if you click on a div that causes some XMLHttpRequest or setTimeout, it won't be recorded). Or, the click may be recorded but you may not like the selector that Selenium chooses for the element. In either case, you'll have to write your own selector based on the DOM structure. To see the DOM structure, open Firebug if you're in Firefox (F12), or open the Inspector if you're on Chrome (Ctrl-Shift-J) Fortunately, Selenium understands a bunch of selector syntaxes, so you can use CSS selectors if you don't know XPath.
If you do decide to use XPath, you'll have to learn it first. I haven't found any good tutorials (and I'm not a fan of w3schools). But feel free to use a bookmarklet to test XPaths that I wrote. You'll probably end up with something like //button[.="text on button"], or //input[#value="text on button"].
You can find button Xpath by using Firebug which is an add-on for Firefox and as above answer Selenium IDE is also another, easier option to find.

Categories