Right click on element leads to new page unable to inspect the element - selenium

I am facing a strange issue while identifying the element on one of the webpages in my application. There are links on the page and I need to click those links and perform the necessary steps.
When I right click on those links then it immediately takes me to that page, I am not able to inspect that link element. When I use inspect tool tip and mouse over any of the link then it highlights a big window where all the links are located and in the elements section nothing shows up, at least I thought I will find those links in view source. Any help is greatly appreciated.
enter image description here

just press ctrl+shift+i
to open the inspect tool , sometime website will have event listeners for right mouse click to some other tasks . IN such case you can open dev tool using this short cut

Related

Inspect Element shows elements for just a few seconds before all of the rows collapse

It was suggested that this had already been answered and then my question was closed.
I've looked at all of the links and I don't see an answer there. Please don't close my question unless you're absolutely sure it's been answered.
Why XPath does not highlighted the yellow mark in Chrome84? (2
answers)
Chrome 84 Inspect element, find results not highlighted in
yellow like before (6 answers) Chrome DevTools not find elements not
search)
I'm writing some Selenium code and need to get the CSS Selector for an item on a page. So I bring up the page and go into Tools mode. It doesn't matter which browser I use - Chrome, FireFox, Edge - when click on the "Pick an element from the page" button (to the left of the Inspector in FireFox) and then click on the item I need the CSS Selector for I see the element in the tools section, but as I'm right-clicking it and choosing Copy->CSS Selector, the table it's in collapses (in a second or two) and I no longer have access to the item I clicked on. I've tried manually expanding the TR in the tools view and drilling down to the TD I need, but the same thing happens.
Anyone know of a way to stop this from happening? I was quick enough to copy a few yesterday but for some reason it seems to be happening faster today and I'm not able to catch it.
Right-clicking the item and choosing Inspect Element was also suggested but that does the same thing. The item shows up in the tools section for about 2 seconds and then the table collapses.
When the element tree collapses, it is a sign that it got updated. This happens, for example, when an iframe's URL or document is changed or the child tree structure gets replaced via JavaScript.
In order to stop this from happening, you can stop the JavaScript execution on the next execution once you see the element you want to inspect. Then you are able to inspect the element using the inspect button.
Firefox
Switch to the Debugger panel.
Once you see the element you want to inspect, click the Pause button or press F8.
Cause the JavaScript execution to stop (e.g. by interacting with the page). You can see that the JavaScript execution is stopped when there is a white overlay on the page and a hint saying Paused at Execution.
Once the execution is stopped, click the Pick an element from the page button in the toolbar or press Ctrl+Shift+C.
Click the element you want to inspect.
Chrome/Edge
Switch to the Sources panel.
Once you see the element you want to inspect, click the Pause script execution button or press F8.
Cause the JavaScript execution to stop (e.g. by interacting with the page). You can see that the JavaScript execution is stopped when there is a hint on the page saying Paused in debugger.
Once the execution is stopped, click the Select an element in the page to inspect it button in the toolbar or press Ctrl+Shift+C.
Click the element you want to inspect.
I found a semi-workable solution. When the item appears in the tools window note it's name before it disappears. Then go to the Search HTML box and type it's name. It still appears and then disappears, but it seems to stay visible longer.

Click not working on combo-box down arrow button karate UI testing

I tried clicking on down arrow button for a Combo Box (Select is not available. Its a React JS application and once I click on arrow button only list shows selection items) using below karate command but click not happened in application and no error displayed. [The same xpath worked in selenium click command,and showing unique item on Inspect search]
And waitFor("//div[#id='root']/div/div[3]/main/div/div[3]/div[2]/div")
And click("//div[#id='root']/div/div[3]/main/div/div[3]/div[2]/div")
Note: Then I tried below command
And assert('//div[#id='root']/div/div[3]/main/div/div[3]/div[2]/div').exists
and got error
javascript evaluation failed: assert('//div[#id='root']/div/div[3]/main/div/div[3]/div[2]/div').exists, :1:19 Expected , but found root
assert('//div[#id='root']/div/div[3]/main/div/div[3]/div[2]/div').exists
It would really help us if you follow this process, it is simple and should not take much time for you to give us a small snippet of static HTML (or you can mix react if really needed).
https://github.com/intuit/karate/tree/master/examples/ui-test
EDIT: you also seem to have mis-matched single and double-quotes in your code.
Also note that you should be able to fire a JS event or click by using the script() API. See this example: https://github.com/intuit/karate/tree/master/karate-core#script
So this is an alternate approach to be able to overcome any tricky situation that comes up.

Element not found in the cache - perhaps the page has changed since it was looked up

I'm using Watir webdriver to click on all the links with the same title on a webpage.
browser.links(:title => 'Hide week').each(&:click)
However, it sometimes happens and I get this error message:
Element not found in the cache - perhaps the page has changed since it was looked up
I need the program to click on a 'turn editing on' button first, then the page will reload and configuration buttons/icons will show. Then each(&:click) should click on the buttons/icons. Is there another way of clicking on a group of links that can avoid 'Element not found in the cache'?
Thank you.
There is no other way apart from initializing the elements again, before clicking them.

Automating "Browse" button event in Selenium

I need to automate the "Browse" button click from Selenium.
For this, I have tried
driver.findElement(By.xpath("//*[#id=\"dnn_ctr383_View_filename\"]")).click();
and
driver.findElement(By.cssSelector("Css path")).click();
Both gives me org.openqa.selenium.NoSuchElementException: Unable to locate element: exception.
I have seen this link here where the author suggest to use AutoIT, but in step 2, the script, the author has created is for IE. Can someone please suggest, how I can automate the "Browse" button click in firefox?
Any help is much appreciated.
Directly send the file path to the id, like so
driver.findElement(By.id("dnn_ctr383_View_filename")).sendKeys("C:\\path\\to\\file");
The above step is the answer for your first two steps
Click on Browse
Select a file to upload
For the third step(click upload), looking at the screen capture I do not see any button which says "Upload". So just click "Save" and I assume that your file will successfully get uploaded.
There are two things that u need to consider here:
Clicking the browser button: Usually handled by an alert or popup, if the driver is not able to find the element by xpath(which u have acquired from firebug or chrome's inspect element) you should consider looking for iframes in the page source. If an element is in a different frame altogether , u need to switch frames in order to find the element like this
WebElement frame = driver.findElementById("name_of_iframe");
driver.switchTo().frame(fr);
now you can find your element using xpath or css selector like u did. Once completed u can move out of the frame by:- driver.switchTo().defaultContent();
Uploading the file from desktop: Since selenium works only on the html in the browser session u invoked from the driver, it can't perform operations on your desktop.Once you are able to click the browser button u can use Auto it(works only on windows) or Sikuli(works with mac, linux, windows and even android) to simulate your events based on the position of your upload button.
Hope this helps

Selenium cannot click tab in magento module detail page

I'm trying to validate data using selenium version 1.0.9 in magento grid and its detail page.
First, I walked through Selenium IDE from login page to module detail page and click the tabs available there. Eventually, IDE generates PHP codes so I put the code into proper location.
Note: Here, I have clicked the two tabs so that the events get recorded into selenium IDE.
Then, I run the code from command prompt using following command:
phpunit --configuration /var/www/tests/phpunit_test.xml
I got the error (something like):
ERROR: Element //a[#id='test_tabs_form_section']/span not found.
I modified the code and tried to open the detail page before executing click to above link i.e. "test_tabs_form_section", I am getting same error.
Another strange this is if I verify any text of detail page and remove the code that calls click to module detail tabs, it is works, not sure why?
But I really want to open detail page and click to tab, get forms element values using xpath and validate the data.
Can somebody help me, please?
Any help or suggestion is highly appreciable!
Looking forward to hear from stackoverflow geeks!
Thanks
In case this helps anybody:
I found out more things work if firebug is active. This actually makes sense cause firebug will show the final DOM tree in all it's debugging screens, so it's possible selenium is now able to reconstruct the element path because firebug altered the internal DOM.
If something doesn't work with the default element selection created by Selenium IDE, try switching it over to xpath:id-relative. You're already using that in your question, so maybe you there's an even better selector or you will need to resort to using clickAt instead of click.