PHPUnit, fill an input that is not contained in a form - input

My question is really simple,
I work on a site where to access login form, user need to fill a first email input, then click on a 'next' button and then access the 'real' login form.
I try to build a unit test with PHPUnit but i dont find the method to fill this input while it's not contain in a form.
$mail = self::randomMail(10, "#yop.com");
$input = $crawler->filter('input#emailValue')->first();
$input-> ???;
$link = $crawler->filter('div#btn-next')->first()->link();
$crawler = $client->click($link);

Related

How can I test that Browser tooltip is shown?

What do I have:
Laravel 5.5
Laravel Dusk 2.0.14
How can I test (assert) that browser tooltip
was shown, when I'm trying to submit a form without filling required field?
What I've tried:
$browser
->assertSee('Please fill out this field');
But it didn't work.
You can get the message with JavaScript:
$message = $browser->script("return document.querySelector('input[name=foo]').validationMessage")[0];
$this->assertEquals('Please fill out this field.', $message);
Note that the message will always be set as long as the input's value is invalid. This assertion also works before you press the submit button.

How to validate dynamic web content in a dropdown list using selenium?

Just for curiosity I was testing an application and trying to automate it. I was testing Momondo.in where I wanted to validate the outputs displayed in the list but the contents are in strange format how am I suppose to handle such kinds of elements. Just for example you can go to the website and type "b" in the 'From' option we get 6 options in form of list now I want to save all of them in a ArrayList in JAVA and then check if the first element is 'b' or it contains '-b' or not for validation thanks for help in advance.
driver.get("https://www.momondo.in/");
driver.findElement(By.cssSelector(".searchFormWrapper input[name='origin']"))
.sendKeys("b");
Thread.sleep(2000);
List<WebElement> options = driver.findElements(
By.cssSelector("div[id*='origin-smartbox-dropdown'] ul > li"));
for(WebElement opt:options) {
String airPortCode = opt.getAttribute("data-apicode");
String airPortShortName = opt.getAttribute("data-short-name");
String airPortFullName = opt.getText();
// It's up to you to determine to check which one of
// `airPortCode`, `airPortShortName`, `airPortFullName` includes `b`
}

How to prevent Google Chrome from saving passwords in ASP.NET MVC 4 after pressing submit button?

Good Day
Hi i have developed a small log in screen in MVC whenever i press submit button it always offers me whether
do you want to save password
i want to disable that option
i can disable that setting from browser
Is it possible to do it using java script or through c#
i tried to set the text box property auto complete=off but it does not work it is still saving password
i even tired to set the property of form tag to auto complete=off
but even that does not work
#Html.TextBoxFor(model => model.UserName, new { #class = "Login_txtType", #maxlength = "50", autocomplete = "off" })
This is now part of HTML5, and according to that standard you can add autocomplete='off' to the form tag then autocomplete='off' will be applied to all fields within the form.
Example :-
<form id="form1" method="post" autocomplete="off">

WebDriver SendKeys Doesn't Send Value

I am trying to run selenium webdriver, imitating typing something to textbox and submit it.
I have this following code:
WebElement element = null;
element = waitForElementPresent(tFByCssSelector,timeoutValue);
element.clear();
element.click();
element.sendKeys("Input String");
The code successfully type "Input String" to the textField, but when I submit the form, it says the form is empty (The form had been set to catch empty input exception).
I wonder why sendKeys does not set the value of the text field even though it has typed the wanted value into the text field.
Try to tab out of the field:
element.sendKeys("Input String");
element.sendKeys(Keys.TAB);
It may be that the field value only gets set on blur.
As I see, all looks okay in your selenium code. I believe there is some problem with your HTML form.
The form should have proper action for receiving the values. A sample form is provided below.
<form action="http://foo.com" method="post">
<input name="say" value="Hi">
<input name="to" value="Mom">
<button>Send my greetings</button>
</form>
Based on what you use in method parameter, you will get the form data in POST or GET variables.
Also you don't need to click on the element before sending keys in Selenium.

webbrowser control login problem with password

I am using webbrowser control for automate login in https://www.itslb.com/tms/ website i have written code also but password input box doesnt hold any value username hold so could anyone tell me why happen this
my code like below
Dim frmform As HtmlElement = WebBrowser1.Document.Forms("aspnetForm")
frmform.All("ctl00_lnkLogin").InvokeMember("Click")
frmform.All("ctl00_txtUserName").SetAttribute("value", sUserID)
frmform.All("ctl00_txtPassword").SetAttribute("value", sPWD)
frmform.GetElementsByTagName("select")(0).Document.GetElementsByTagName("option")(1).SetAttribute("selected", "true")
'frmform.All("ctl00$cboTerminal").InvokeMember("SelectedIndexChanged")
'frmform.GetElementsByTagName("select")(0).Document.GetElementsByTagName("option")(1).SetAttribute("selected", "true")
frmform.All("ctl00_btnLogin").Enabled = True
frmform.All("ctl00_btnLogin").InvokeMember("Submit")
Thanks in advance
I have used InnerText successfully for login boxes before(that is what you would use in a regular COM method, anyway):
I am guessing that sPWD is a var for your password, and that "ctl00_txtPassword" is the id for your password box.
whatbrowser.Document.GetElementById("ctl00_txtPassword").InnerText = sPWD
You might also try this:
frmform.Document.GetElementById("ctl00_txtPassword").SetAttribute("value", sPWD)