When I write the blow code in Watir-webdriver:
$browser.checkbox(:index,0).click
It gives the following error:
element not visible (Session info: chrome=48.0.2564.97) (Driver
info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)
and then I have written this code $browser.input(:index,0).click then it reports this error:
unknown error: Element is not clickable at point (952, 17). Other
element would receive the click: ...
(Session info: chrome=48.0.2564.97) (Driver info:
chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)
But the element is clearly visible and also the given above two lines of code cleanly works in watir-classic, we do not even need to scroll the screen.
Can anyone suggest me why it is the case? Why this watir-webdriver is not as comfortable as watir-classic?
<td class="centred"> <label class="label-checkbox"> <input type="checkbox" data-ng-model="cover.IsSelected" class="ng-pristine ng-valid"> <div class="fake-checkbox"> <span class="glyphicon glyphicon-ok"></span> </div> </label> </td>
The first thing you need to do is to update your chromedriver, as version 2.9 is 2 years old. That binary needs to be kept up to date with current versions of chrome. It is quite likely that this alone will fix your issue.
If it is an issue of visibility... The purpose of Watir (and Selenium and WebDriver) is to mimic the action of a user. If the checkbox isn't visible to the user, you shouldn't be able to click it in your test.
If the checkbox is something that isn't visible at first, but then becomes visible, you can do: browser.checkbox.when_present.click (note that index: 0 is the default behavior and is not necessary)
If the checkbox has some exciting javascript things that are covering it up in a way that it is never going to be visible, and clicking on something that is visible throws the "Element not clickable" error, you might have to do browser.checkbox.when_present.fire_event :click
That method does not mimic what a user actually does on your site, so it should only be used as a last resort.
Related
I'm making a web application using ASP.NET Core 2.2 and trying out Razor Pages more or less for the first time. When using "asp-for" attributes in order to bind an HTML input to a PageModel property, everything works just fine, but then when editing any attribute in any HTML element in the script that also has an "asp-for" attribute defined, all "asp-for" values for every other element but the one I'm editing are scrambled/wiped out.
I'm using the latest version of Visual Studio 2019 Community Edition and all extensions are up to date. ASP.NET Core 2.2 and all included packages are their respective latest stable versions.
I've tried disabling all extensions one by one, restarting the application each time to see if one of them is causing any strange behaviour- I'm not using many to begin with though, mostly just GitHub integration and "Format on Save" at the moment.
I've also tried going through the preferences and unchecking many of the validation options for HTML and C#, and things like automatic quotations for new attributes and closing bracket insertions... basically, anything that I thought could potentially have an impact. Nothing has worked.
An example would be something like:
<div>
<table>
<tr>
<td>Entry ID:</td>
<td><input type="text" asp-for="EntryID" /></td>
</tr>
<tr>
<td>Entry Name:</td>
<td><input type="text" asp-for="EntryName" /></td>
</tr>
</table>
</div>
When editing any of the attributes for any element with an asp-for attached, the asp-for value for the other tags will be scrambled. This happens both when I use the backspace key or the delete key, so it doesn't appear to be keyboard-shortcut related.
Here's a gif of the issue (not enough reputation to post images apparently- apologies).
https://drive.google.com/file/d/1f1gZSvGrQ8ehpTNwKOA2YbCkfLhx_o-M
If anyone has any ideas, I'd be quite grateful. This is really killing productivity and I haven't really come up with any ways to consistently get around the issue- usually when deleting the entire attribute all at once (which still scrambles other values), I can hit Undo once and it'll undo the scrambling but not the deletion itself. That's not 100% though, so it's just a big headache all around.
UPDATE 7/31: I've gone ahead and reported this to Microsoft as per Peter B's suggestion. A link to the report can be had here if anyone comes along with the same issue and are wondering at the progress there.
Your gif shows it happening for the id attribute, but you shouldn't try to specify the id because the Input Tag Helper already does it for you:
The Input Tag Helper:
* Generates the id and name HTML attributes for the expression name specified in the asp-for attribute. [...]
Source:
https://learn.microsoft.com/en-us/aspnet/core/mvc/views/working-with-forms?view=aspnetcore-2.2
I agree that it seems to be acting a bit weird. If it persists, you can try reporting the weird behaviour, as described here: https://learn.microsoft.com/en-us/visualstudio/ide/how-to-report-a-problem-with-visual-studio?view=vs-2019
I am experiencing IE browser links flashing issue when I run test automation written in Ruby Cucumber using Selenium WebDriver.
Scenario: Navigating to Reporting home page.
Given I see menu Reporting available.
When I navigate to "Annual Reporting".
Then I see the correct header on Annual Reporting page.
home_page.rb (Approach 1: using page_object)
link(:annual_reporting_link, :id => 'annualReportingLinkId')
def go_to_reporting
mouse_over_home
wait_until(5) do
annual_reporting_link
end
end
Result: Could not click on the link because of the link flashing.
Then I tried the following (Approach 2: Using send_keys)
#browser.find_element(:id, 'annualReportingLinkId').send_keys :return
and
#browser.find_element(:id, 'annualReportingLinkId').send_keys(KEYS.ENTER)
but it did not work either. I am getting this error when run the test:
Selenium::WebDriver::Error::ElementNotVisibleError: Cannot click on element
The HTML:
<div id="homeMenu">
<ul>
<li class="has-sub"><a class="homeButton" href="/report-web"></a>
<ul id="homeLinks">
<li id="report1LiId"><span id="report1LinkName" class="disabledLinksText">Report 1</span></li>
<li id="report2Id"><span id="report2LinkName" class="disabledLinksText">Report 2</span></li>
<li id="annualLiId"><span id="annualReportingLinkName">Annual Reporting</span></li>
<li id="administrationLiId"><span id="administrationLinkName" class="disabledLinksText">Manage Users</span></li>
</ul>
</li>
</ul>
</div>
Test automation is able to expend the home menu, which contains sub-menus - hyperlinks. But after mouse_over_home (the home menu), the sub-menu started flashing. I need to click on "annual_reporting_link" to go to this reporting page, but because of flashing, the test automation cannot click on it at all.
Anyone has a solution that worked for you? Please share your solution.
Environment:
Ruby: 1.9.3
Cucumber: 2.1.0
Selenium Webdriver: 2.53.4
page-object: 1.2.0
IE: 11
I've had this issue before using Selenium Webdriver and IE. I found that it was a bug between my version of IE and Selenium Webdriver.
When I experienced this problem, I put a break-point before the link was clicked and debugged the test, I then manually tried to click the link in IE and I was still unable to do so 9 times out of 10 because of this bug, the link was simply ''flashing'' and unresponsive.
I'd recommend upgrading your version of Selenium Webdriver to version 3.0.0, that should fix the problem.
If you don't want to make the jump to Selenium Webdriver 3.0.0, You need find out the exact version of IE 11 you're using. Try to upgrade or downgrade your version of IE 11, this should also fix the problem, but you may find you're stuck on a version of IE 11 until you upgrade to Selenium Webdriver 3.0.0.
Antoher solution is to set the persistent hovers to false within your IE profile, something like this:
profile = Selenium::WebDriver::IE::Profile.new
profile['enablePersistentHover'] = false
driver = Selenium::WebDriver.for :IE, :profile => profile
I would like to know how to use in bash in order to first chose some parameters on a internet page then upload a *.txt file, and be redirected(after file analysis) to an other page and finally to press on a button to download a new file all this in bash.
I found a lot of information on forums regarding cURL and how to fill in forms and download files but very often you could juste download the file by accessing with URL/file.txt. Here it seems to me that it is different because the page uses some code in order to analyse my .txt file and output a new one.
The site is MSC server and I need to check the CADD checkbox in option 2, upload a *.txt by choosing file, click on upload & submit and after beeing redirected click on download result. Here is the html important parts
first page:
<form action="UploadServlet" method="post" enctype="multipart/form-data">
Apply MSC to: <input TYPE=checkbox name=measure1 VALUE=CADD> CADD 1.3
<input type="file" name="fname" id="fileChooser" size="16" /><br>
<input type="submit" value="Upload & Submit" size="20" onclick="document.getElementById('pleaseWait2').style.display = 'block';"/>
second page:
<form action="DownloadServlet" method="post">
<input type="submit" value="Download Result" color ="#ff0000" size = 200>
That is what I tried
curl -L -F measure1=CADD -F fname=#file2.txt -F submit="Upload & Submit" http://pec630.rockefeller.edu/MSC/
That was what I tried for the first page but it only shows me on the terminal the HTML code of the same page not the one where I should be redirected. And even if it gives me teh HTML of the second page, I've got no idea on how to download the file, firstly because the URL changes so I don't know what to put for the URL (I think it's something with cookies but I'm not sure) and secondly even when I try to click on a button and to download a file (for example, ont the example button on the first page, it still shows me the HTML code and it doesn't download the text file).
I hope I was clear enough and that you will be able to help me, I'm still a beginner in programmation and It's been 10 hours since I started to find how to do this:/.
Also since it's my first question (I normally always find previous questions that were like mine) I take this opportunity to thank you are all because your answers are always very clear, and I hope I'll be able to help other people to when I'll understand more of what I do :)
I didn't found the kind code I was looking for (I suppose it is a problem with cookies but even when I tried to handle them with cURL it is not working) but I found a way to get around "any" (I think) cURl problems. Maybe it will help others:
Just copy the headers your computer sends to the site as you a doing what you want:
in google chrome
view -> developer -> developer tools -> do what you want to -> right click on the name which pops up in the side bar -> copy as cURL -> paste it in your code
It's certainly not the best way to do it but if you're desperate as I was it works:)
I am using ruby/cucumber/watir-webdriver and the page-objects gem to run my tests. My tests are usually run in firefox but decided to give chrome a try. While the click works in firefox it does not in chrome. Here is the sample html code:
<form id='test-form' method='post' class='validate-inline'>
...
<div class='margin-top'>
<input class='btn' data-disable-with='wait...' type='submit' value='Submit Form'></input>
</div>
</form
In my class page I have the button declared as the following:
button(:submit_form_btn, :value => 'Submit Form')
And call it this way:
submit_form_btn_element.when_present.click
I do see the button text change to 'wait...' for a few seconds then returns to 'Submit Form' but does not seem to submit the form. As mentioned before it works with firefox and when clicked manually. Just seems to be an issue in Chrome. Any ideas how to get around it?
I tried clicking the div, and tried clicking the button twice but same issue.
As always your help is appreciated. Thanks.
I know this question is little old now, but I thought I'd post in case this helps anyone.
Most of the times I've run into similar issues, it was caused by an update to Chrome that caused issues with the version of the watir-webdriver gem (or one of it's dependencies) or with the version of chromedriver that I was using. I've had success in the past by updating my gems and chromedriver and the other times I've had to roll back the browser version to the previous release.
It's not ideal to be testing on an older version of chrome but it worked fine as a stop gap until the issue was fixed.
If you do go for the previous version of chrome approach, make sure to log a bug ticket if there isn't already one there.
I am facing intermittent issue in Clicking on a button or a hyperlink on Firefox.
I am using webdriver version 2.27 and FF17.
The buttons are simple html button -
<input class="btn" type="button" title="AddP" onclick="navigateToUrl('/p/tyy/SelectSearch?addTo=006y67&retURL=%2F00999yu2Boy9','MM_LIST','addP');" name="addP" value="Add P">
I use locator as : name=addP
For hyperlinks I use locator as : link=hyperlinktext
The Click will not fail with any exception, it will simply highlight the button or link, but not perform the actual click.
The frequency of failure is once in 3 times.
Thanks
Sky
Upgrade to at least Selenium 2.28. There were some bugs for Firefox 17 before that.
Here is what i found :
Issue 1: I was using By.linkText("test test").click which should have been By.partialLinkText("test test").click . Thanks to stackoverflow for the answer.
Issue 2: I rewrote the css locators for failed button to start from class of some parent above.
For e.g. instead of
css=input[name='j_id0:j_id2:j_id3:j_id4']
I am now using
css=.individualPalette input[name='j_id0:j_id2:j_id3:j_id4']
And it works all the time. I am not sure why??
I am still to rerun my scripts couple of more times to be sure these helps.