unable to Pass hyphen or - character using Selenium webDriver - selenium-webdriver

from web driver for one textarea/input text if i am passing SendKeys("'1-ABCD'"),in text box onle '1ABCD' get enter.
Can anyone help me how to pass a value such that value get accepted as '1-ABCD'
Thanks.

Related

Input pattern - Mobile number - Start with a specific numbers and character

I'm working with react js and i have a input field type tel the backend was designed to accept the phone number starting with +251 if it doesn't start with that it will not send. so what attribute can i add to make that happen and to be visible like a placeholder but character "+251" are in the input the user cant change it but add on to it?
Found this for you https://www.30secondsofcode.org/css/s/input-with-prefix, just an example of how you can handle this with a span next to your input

URI malformed, cannot be parsed - while connecting to mongdb using MongoDB Compass connection string

I'm trying to connect to mongoDB with the new password with special char as shown in the screenshot. It gives error as URL malformed due to special character in it.
Initially I was able to connect with normal password.
I tried to add escape characters in password with no luck.
Does anybody have came across this situations or know the solution? Any leads highly appreciated[![enter image description here][1]][1]. Thanks.
Click on the Fill in connection fields individually then input the fields.
It will create the URI with escaped characters for you.
If your password includes special characters you need to encode all special characters. you can find it on this link: https://www.w3schools.com/tags/ref_urlencode.asp

selenium webdriver find element by 'href' not working using java

I am creating a page Object model using selenium web driver and trying to link an element which has a 'href'. By creating in this way
[element = driver.findElement(By.partialLinkText("signin")).click();]
I am getting an error like
cannot covert from void to web element.
Can anyone can help me with this
First select element in browser, and copy it's selector(inspect -> copy selector). Then use it as cssSelector. Try not to use link text coz it is language dependent.
hi you are getting above error because
element = driver.findElement(By.partialLinkText("signin")).click();
you are trying to perform action (i.e click) and its object identification (element =...)
together whic h is not correct to make it work plz do it like below
element = driver.findElement(By.partialLinkText("signin"));
element .click();
Also why are you getting the error "cannot covert from void to web element" cause the type of .click() is void for more information please look at official documentationhttp://seleniumhq.github.io/selenium/docs/api/java/index.html
now it will stop giving you error hope this helps you

Selenium WebDriver cannot locate element within an iframe, and throws NoSuchElementException

I realise there are several queries on here for this same problem but none of them provide a solution to my particular problem.
I am running a web driver test that tries to fill out a form for a mail website to find postcodes based on address details. I keep getting this error when trying to locate the first text box:
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"css selector","selector":"#ctl00_BodyContent_txtBuildingNumber"}
I have used xpath and the id to try and locate the element but I keep getting the error. I can see that this element is present when the webdriver is running and I have been able to locate another text element on the page and enter text, but I keep getting this error for this field and other fields within the frame.
I am guessing that the problem must be to do with the fact that this field is part of an iFrame.
I have used implicit waits within the test but with no success. I still get the error.
By the sounds of it you'll need to first switch to the iframe element that contains the element that you want to interact with. (Although without seeing the relevant HTML this is a bit of an extrapolated guess).
driver.switchTo().frame();
eg:
driver.switchTo().frame(1);
driver.switchTo().frame(driver.findElement(By.id("id")));
When you've finished interacting with the elements within the frame, you'll need to switch back to the main webpage.
driver.switchTo().defaultContent();
Check your xpath .
try to use simple
driver.switchTo().frame(1);
with wait statement.
sorry a little correction the following worked for me
driver.switchTo().frame(driver.findElement(By.xpath("//*[#id='page-15']/div/p/iframe")));
//*[#id='page-15']/div/p/iframe is the xpath of the frame in which the button i was trying to click was located. (driver is of type WebDriver i.e WebDriver driver ) thank you
The following worked for me
driver.switchTo().frame(myd.findElement(By.xpath("//*[#id='page-15']/div/p/iframe")));
//*[#id='page-15']/div/p/iframe is the xpath of the frame in which the button I was trying to click.(driver is of type WebDriver i.e WebDriver driver)
thank you
you can use wait statement and after using the wait statement use simply
driver.swithcTo().frame();

I capture the same web page as string for many times, but the screenshort strings are not always the same

Thanks for Take a screenshot with Selenium WebDriver
I wrote a selenium test case and wanted to compare a special page's old image and new image.
Firstly, I captured the page image as string and stored it to a file.
String oldCapturedString = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.BASE64);
I didn't do any change for my web programs.
Then I run my selenium test case again and captured a new image as string.
String newCapturedString = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.BASE64);
I found the oldCaptureString wasn't always the sample as newCapturedString,
but sometimes the two string were the same.
I want to know why the selenium captured strings are not always the same at different time, or I made some mistakes.
many thanks

Resources