I am new to Watir and have a scenario which is a blocker for me. I have to click on the below link. It is shown as a link. It is any normal forgot passord?? click here .... option which is there in the application which I am testing. Please advice how to click on this link. I have tried the below mentioned x paths as well but no luck.
<a href="javascript:forgot_password()">
x paths used with no luck :
1> ie.link(:xpath, "//img[#onclick='javascript:forgot_password()']").click
2> ie.link(:xpath,"//a[#href='javascript:forgot_password()']/").text # => "Click Here) "
3> ie.element_by_xpath("//link[contains(#href , 'javascript:forgot_password()')]/").click
Did you try this?
browser.link(:href => "javascript:forgot_password()").click
First check if xpath works on your system: appart form watir gem you have to have installed REXML with version greater than 3.1.6.
And i don't know what could be wrong with your code because I don't know which page you are accessing, if you can, please give us the link. Personally I would do something like this, but there may be lots of alternatives.
ie.link(:xpath, "//a[contains(#href='javascript:forgot_password')]/").click
Your xpath selectors look quite confused looking at them.
Line one
ie.link(:xpath, "//img[#onclick='javascript:forgot_password()']").click
intends to find a link, but looks for an image. Would that ever work?
Try using
ie.link(:xpath, "//a[#onclick='javascript:forgot_password()']").click
or
ie.link(:xpath, "//a[#onclick='javascript:forgot_password()']").fire_event('onclick')
It's potentially just not triggering the onClick event when using .click on an element. I can't remember whether it does or not.
Without seeing the page, I can't really be certain, but you might not need to be using xpath to find this element at all.
If the text is "Click here" you could use that as the locator instead.
ie.link(:text => "Click here").click
... or the equivalent .fire_event('onclick')
It's incredibly tough to diagnose the problem without seeing the html in question, and accurate Watir being run against it (i.e. copied and pasted directly from your file), so these suggestions are pretty much shots in the dark.
Related
Every other snippet is working, but !+tab is not.
! snippet is not working
other snippet is working
I am using Visual Studio Code. I'm using 1.69.0. It was working before, but I wanted to add net html file, named that new.html, because I had index.html already. After that this script stopped working on every html file, but other scripts like "a", "div" etc. is working.
The v1.69.2 recovery release is out now. Emmet in html is working as it should for me now.
Looks like it will be in the Recovery Release, see https://github.com/issues?q=is%3Aissue+label%3Acandidate+repo%3Amicrosoft%2Fvscode+repo%3Amicrosoft%2Fvscode-internalbacklog+repo%3Amicrosoft%2Fvscode-remote-release+milestone%3A%22June+2022+Recovery+2%22+.
Don't know when the recovery release to Stable - presumably v1.69.2 - will be released. The .1 release is out and the fix is not in it.
It has been fixed though, see https://github.com/microsoft/vscode/issues/154375, and should be in the Insiders Build tomorrow (07/13/2022).
Testing the latest Insiders: ! is working. As is ul>li*3 type expansions (although that never stopped working for me - but it has been reported elsewhere). Should be in the v1.69.2 release out soon.
It is a known issue with the v1.69 release, see html emmet suggestion not automatically display or https://github.com/microsoft/vscode/issues/154517 for example. Lots of issues on github on ! and * not working.
So the emmet snippet will not appear automatically when you type !, but you can press Ctrl/Cmd+Space (which is the command Trigger Suggest) to make it appear and select normally.
Try Ctrl/Cmd+Space for anything emmet-related nnnnnot working in vscode v1.69.
You could also go back to v1.68 to solve the issue.
Try to write "doc" instead of "!". "doc" works for me.
On Windows 10, this worked for me:
Go to "Settings" and type "emmet.trigger" in the search
A checkbox for "Emmet: Trigger Expansion On Tab" will appear
Check the checkbox for allowing Emmet to trigger expansion on tab
After I did that, it worked just fine for !+TAB and any type of mulitpliers (i.e. li*4+TAB).
You need to check this option or put "emmet.triggerExpansionOnTab": true in settings.json to use the emmet abbreviation pressing TAB. I realized this ones what is not working:
!, lorem, >, and .
Examples of use: ul>li, li3, ul>li*3
None of them shows the preview of the emmet, and you can't use them pressing TAB without enabling the option that I sayed above, and even checking the option you won't be able to see the previews, you'll need to know them by yourself and press the TAB even though nothing showing that it's a emmet abbreviation.
You can use CTRL + SPACE too.
Edition Windows 11 Pro
Version 21H2
VSCODE Version 1.69.0
I had the same issue with the ! not working. I found another shortcut that does the same thing: type html:5, and press enter.
Looks like a bug, I have the same problem with 1.69.1, the VSC team is aware and fixing it. Should be fixed with the next release soon.
Meanwhile, you can use either HTML:5 or doc
meanwhile use "HTML:5"
enter image description here
or use "doc"
enter image description here
While #Mark's answer works, another work around would be to use the html:5 snippet which still works as expected in v1.69
Yes, I am facing this issue too since the latest update.
Somehow the solution I have got is :
You can check the box “Emmet: Use Inline Completions”
In settings by typing “emmet” in the setting’s search.
You can see the suggestion now and choose it by pressing the tab.
This is the solution I have got till now but hoping that we could have the previous version back.
On a webpage I have a "onclick" event in a <div> element. Right clicking it on Firefox and inspecting it brings up the dev console. At this point I see the function it is being called but I'm unable to lookup the code or the file that this function is pointing to, what am I missing?
The body of the javascript function can be found in respective .js library. In developer's tool, click the tab "Debugger". It lists all .js files which might contain the function you are looking for.
Just found the answer while trying, it seems I were using # rather than # which is used to lookup a function definition!
Have you tried firebug add on for Firefox?
I think it is clearer to see it with firebug. I'm sorry if it's not what you are looking for, because i can't suggest it on comment
I just re-did a site, when I check it for broken links (using brokenlinkcheck), it comes up with 73 broken links that are all like this: www.example.com/site/numbers are here/${href}. Support over there tells me that (this quote is from one rep who got 'news' from another):
QUOTE: "did not find an issue. They had mentioned that the examples I showed were referring to tags with an attribute data-href that have the broken url. There type of links are not clickable and can not be visited and are mistakenly recognized by the tool as broken links. The link checker mistakenly alerts for 'data-href=...' (its not an href attribute)." END QUOTE
BUT, seeing the link in my email to them, I CAN click on it (why are they saying it's not clickable???). My main question is: will Google see this as broken links? Support is telling me there's no issue. But it looks like an issue to me. I cannot go in and fix myself, I would need specific wording to try and convince support to fix it. So, if you DO believe it is a problem, could you suggest how I word that in an email to support, who seems to think it is fine? Thanks so much for your help.
Without a URL to check it, or a sample of the html code, it is hard to say for sure. What the rep said does make sense, it is possible for the broken addresses to only be present in a data- attribute and therefor not to be clickable, Google would also not take these URLs into account while crawling the site.
Yes if you take the URL out of the data- attribute and paste it into an email it will be clickable but not clickable on your site. Again without a link to the site hard to say for sure.
Can you by clicking around your site get to and click the broken link? If not then it may just be a problem of the tool you are using.
Is there ANY way to click a JavaScript link using the Watir webdriver? I've looked around for hours and nothing has helped me.
Here's what the link looks like: MULTIPLY YOUR BTC
I've tried using browser.link(:id, "double_your_btc_link2").click and a bunch of other stuff including Xpath (it kept saying it couldn't follow the path) and nothing works. Is it even possible?
If you need the page, here it is.
That should have been:
browser.link(:id => "double_your_btc_link2").click
Sorry to waste your time, guys. I just used Firefox instead of Chrome and it worked fine. This isn't even the first time I've had a problem with accessing JavaScript elements in Chrome...thanks anyway.
I was looking into making Firefox addons, and I need some help.
Is it possible to edit an HTML page that is open in the browser with javascript?
For example:
User types in "google.com"
Addon is activated
Javascript changes contents of "google.com" to maybe say "Hello!" at the bottom.
Of course this isn't specifically what I want to do, but a push in the right direction on how to accomplish such a task would be great.
~Carpetfizz
From within a Firefox addon this is obviously possible as many extensions do this.
If you, however, simply want to modify the DOM and nothing else than I would recommend taking a look at greasemonkey. Loads of example scripts around to do this: http://userscripts.org/
And the added benefit, if written correctly they also work in Chrome and other browsers.
Yes, it is. You must find a tutorial about javascript DOM manipulation