How to find element by xPath in Ghost Inspector - automation

Hi have to click an element using its xPath in Ghost Inspector but its not working for me, the syntax I tried were:
"xpath=".XPATH
"xpath="XPATH
xpath=.XPATH
xpath=XPATH
all the above thing that I tried didn't worked and Ghost Inspector was saying:
"ELEMENT NOT FOUND"
can any one please help me finding element using its xPath in Ghost Inspector

you should use xpath=//
For example: xpath=//*[#id="main-container"]/div[1]/my-header/div
Documentation: https://ghostinspector.com/docs/test-editor/#targets

I am using developer tools in Chrome and there I can choose (by mouse right click) what value I want to copy. Try to copy xPath, it should work, I use them a lot.

Related

What is the xpath for this upload button?

This is a dropdown menu. Can someone help to write the relative xpath for this to use as a locator in selenium automation?
I have tried with //a[text='Upload']
You try by right clicking the element in the browser under inspect element to get this (here showing post your answer in stack overflow for example, after the right click) then copying the XPATH, this would give another way of the same xpath, and referring this xpath might be a solution to your problem.

How to find xpath without firepath into firefox version 57.0

Facing difficulty to find xpath without firepath in new Firefox version 57.0.
In the new Firefox version, firepath is not supported.
Can anyone please suggest a new way for using xpath?
you can try ChroPath which is the best replacement of firepath.
It's not Firefox, but I like to use Google Chrome for this. Press F12, this opens the developer tools. Then click anywhere in the HTML structure and press Ctrl + F or Cmd + F if you're on a Mac.
In the search bar that appears you can search by XPath, Css selectors or strings. So if you type //div/div/form for example, you can immediately check if the XPath works.
You can also right click on an element and choose copy > xpath
Step 1: Right click on the web page and click on Inspect Element or Ctrl+Shift+Q
How to inspect element
Step 2: Click on inspector Inspector image
Step 3: Verify in console
Temporary solution for a 64 bit Windows OS: Install 46.0.1 firefox 32 bit version on your system. You can use this lower version of browser for debugging xpaths using add-ons.

cannot unselect checkbox element not visible

I'm using robot framework selenium library, trying to unselect checkbox which is checked using
unselect checkbox|id=blahblah but I get element not visible exception.
But when I do select checkbox|id=blahblah it works.
Should't it give element not visible consistently for unselect/select.
Any ideas how to fix this or work around?
I tried click element but same error
try to do it by "click element" may be it run or cross check your locator.

How to get Xpath of sub menu?

How to get Xpath of submenu when user click on main menu in selenium?
I have tried with finding ID and attribute name but its not working.
Please help
You can try the Firebug/Firepath add-ons if your using the Firefox browser to get the xpath values generated by the tools. If those don't work then share the HTML code for better clarifications.
Probably your element of submenu is not visible at the current time when you are tried find it by ID or Name. You should to make click on Menu and only then try to find this element of submenu by ID or Name - it have to be visible.
If you will not find element of submenu this way, write here HTML-code of page and your selenium-script.

How can I get the XPath expression from a web site's HTML content?

I want to use XPath expressions in Selenium code, but I don't know how to get it from a site's HTML code.
I'm using the Google Chrome web browser.
The easiest way is to inspect the element you want to get the XPath expression for. Then click on the highlighted code and Copy → Copy XPath which give you a full XPath patch you can copy to your code.
For Firefox, you should install Firebug or another extension like this.
As neliCZka suggests, you could also try to build a relative path if its possible by trying to find the proper XPath in the search bar in Chrome after inspecting the element.
I see that someone has downvoted the suggestions to use the Copy XPath option from different inspection tools. That's probably because these paths can often be difficult to maintain as the application changes, won't work in Selenium because they're not sufficiently unique, or can just be unreasonably complex for complex HTML.
Copy XPath... is useful as a starting point though. If you're not familiar with XPath, this tool can help you to get a better feel for how to apply it to your HTML content, but it's very important to learn how to use XPath yourself.
Right click on the element you want to have an XPath expression for, and then click Inspect Element. A new frame will open with the HTML source code.
Now right-click on the code and select "Copy XPath".
Note: you will have to remove " WITH ' after copying it into your code
Install Firebug for Firefox. ...
Open the website that you want to inspect. ...
Click the Firebug button. ...
Click the element inspector button. ...
Click the web page element that you want to inspect. ...
Right-click the highlighted code in the Firebug panel. ...
Select "Copy XPath" from the menu.
You can press F12 to get the check page, select your hoped HTML code, and hit the mouse 2. It has the copy option, and there is a copy XPath.