I'm able to enter this page here and click confirm cookies "Got it" button, click "play demo" button and click confirm age button to enter this page here (TOKEN CREATED FOR EACH DEMO FOR THIS LINK)
I'm also able to extract the value from the round count using this xpath here #class,'coefficient and also extract the finished round count value using this xpath here #class,'flew-coefficient
What I want to do next is to locate the input element and enter the value amount on the left hand side and click the big blue "bet" button on the left hand side but I can't seem to locate the value input "1.00" and the button on the left of the page. Please see my code and assist if you can.
To set the desired input value please try this:
String inputXpath = "//input[contains(#class,'roboto-font-b')]";
WebElement input = driver.findElement(By.xpath(inputXpath));
input.click();
input.sendKeys(Keys.chord(Keys.CONTROL,"a",Keys.DELETE));
input.sendKeys("20");
To click the Bet button please try this:
driver.findElement(By.xpath("//button[contains(#class,'success')]")).click();
Sorry to come back this late, I had some personal stuff to attend.
I managed to use the following xpath to find the input but only one text is deleted:
String inputXpathL = "//app-bet-control[#class='bet-control double-bet'] //div[#class='second row']//input[#class='roboto-font-b']"; WebElement inputTargetL = driver.findElement(By.xpath(inputXpathL)); inputTargetL.click(); inputTargetL.sendKeys(Keys.chord(Keys.CONTROL,"a",Keys.DELETE)); inputTargetL.sendKeys("10");
For the button I used the following xpath but the button is unclickable and there are no exceptions or errors:
findElement(By.xpath("//app-bet-control[#class='bet-control double-bet']//button[#class='btn btn-secondary btn-sm betopt ng-star-inserted']")).click();
Related
I want to webscrape https://appscvsmovil.supercias.gob.ec/portaldeinformacion/consulta_cia_menu.zul?expediente=87379&tipo=1
Where "expediente=87379" will always have a different number.
I'm trying to click on "Información General" and then, on the Pop-up window, I want to obtain the data right to "Tipo Compañía" which is a Text Box.
Then, I want to click in "Ubicación" tab and get the text from "Provincia" (the text box next to it) and finally click on "Contactos" and get some other fields.
I can open the web browser with Navigate URL command but I can't click or get text.
IE.Document.All.Item("id#").Click
IE.Document.All.Item("id#").Value
For Each MyHTML_Element In IE.Document.getElementsByTagName("a") 'I also tried with div
If MyHTML_Element.innerText = "Información General" Then MyHTML_Element.Click
Next
How do I tackle this webpage and get any information from it?
There is a button on a website at the end of a form that I cannot seem to click with WWW::Mechanize. Here is the bit of HTML pertaining to this button:
<input type="submit" class="saveButton" value="Login">
When I print $mech->find_all_inputs();, I get return this:
HTML::Form::TextInput=HASH(0x7f8f52cdc450)
HTML::Form::TextInput=HASH(0x7f8f5302b488)
HTML::Form::SubmitInput=HASH(0x7f8f52cdc108)
The third one is the one I want to click. I'm not exactly sure how to click this button even though I've found it. I tried click(field(n => 3)), I tried assigning a variable $submit to find_all_inputs(3), then click($submit);, and no matter what, this button is not clicked.
Can anyone guide me as to how to click this elusive button?
Edit (after question answered)
Interrogating the HTML form found I was actually entering the password for the login into the 'Forgot my Password' field of the form. Why this field was not coming up for $mech->find_all_inputs(), I don't know since "Login" was. Either way, clicking the button takes me to the next page. Thanks!
Since it is the first button in the form, you can write this
$mech->click_button( n => 1 )
or, since it's value attribute is Login, you can do this
$mech->click_button( value => 'Login' )
But since it is the only button in the form, just
$mech->click
should work fine
Did you try to select the appropriate form first, then call click? It says (my emphasis)
Has the effect of clicking a button on the current form.
Find which form on the page you need. Let's say it's form number 2.
# $ua is the User Agent (Mechanize object), at the appropriate page
$ua->form_number(2);
# fill the form ...
my $response = $ua->click();
or
$ua->submit_form(
form_number => 2,
# fields => { name => $value } # can fill it here as well
};
I find click to be perhaps more reliable overall.
To inspect the forms you can use my #forms = $ua->forms. To fill the form you can use select or set_fields, for example. See Form Methods and Field Methods. All this operates with HTML::Form objects so you can use its methods as well. For example, value_names and possible_values are handy.
If this doesn't help please give us more detail -- the web page in question would be ideal.
I have two buttons - Company Email and Non Company Email.
If i select the first , ng-click="flag='Y'" and the second one renders the flag value as 'N'
So now I am trying to disable them when they are selected so user is not allowed to click on the second time, the second click is creating some UI issues which I want to avoid here.
But the ng-disabled is not working at all as expected, it disables from the outlook but we can still click the button and it behaves strangely.
Pleas help-
Code block is added in comments
This seems like a simple enough issue where you would disabled the buttons using a scope variable set once a button is clicked.
<button ng-disabled="flag=='Y'" ng-click="doCompany()">Company Email</button>
Here is an example
My ASP.NET MVC 3 website has code on the server side that checks for the name of the submit button clicked to submit the form. The code works when I use the mouse to click the button, but when I use the Enter key, the form gets posted, but the request doesn't contain the name of the submit button.
Is there some attribute I can set on the submit button to get this to work for both clicking and using the Enter key?
Here is my HTML:
<div>Search:</div>
<form action="/Item/Search" method="post">
<input class="fulltextsearch" id="FTSearchText" name="FTSearchText" type="text" value="" />
<input type="submit" value="Go" name="FTSearchButton" />
</form>
</div>
On the server side, I have a custom model binder that uses the following code to determine if the user clicked the submit button.
// See if the value provider has the required prefix
var hasPrefix = bindingContext.ValueProvider.ContainsPrefix(bindingContext.ModelName);
var searchPrefix = (hasPrefix) ? bindingContext.ModelName + "." : string.Empty;
var searchButton = GetValue(bindingContext, searchPrefix, "FTSearchButton");
// If this value doesn't have value, the user didn't click the button so exit
if (string.IsNullOrEmpty(searchButton)) {
return null;
}
private static string GetValue(ModelBindingContext context, string prefix, string key) {
var result = context.ValueProvider.GetValue(prefix + key);
return result == null ? null : result.AttemptedValue;
}
Here is the problem I'm having with this. I have a page that displays a list of items. I have a 'search' textbox and a submit button in an HTML form. When the user enters text in the textbox and clicks the search button or uses the enter key, the page posts the form data via HTML GET, and returns the first eight records found. The page then displays page links for additional pages. The problems is that when the user clicks a page link, the form data is all blank, and my filter information is lost (the form isn't posted with the form value when using these links). So, I end up displaying a blank list of items (blank searches returns zero results) instead of paging the data.
By adding the check for the button name in my form data, I could determine whether or not to simply page the data, or do a new look up.
I wouldn't rely on this. There are plenty of documented bugs with this scenario. Just add a hidden field with name='submit'. That way it wouldn't be too hard to recode the backend.
<input type='hidden' name='submit' value='FTSearchButton'/>
So, I researched this last night and almost got somewhere. Then this morning, I really did get somewhere and here's where I ended up.
Apparently the W3C standards for form submission are pretty lax when describing the functionality as it relates to the Enter button and submitting forms. It seems they determined that
When there is only one single-line text input field in a form, the user agent should accept Enter in that field as a request to submit the form.
So that leaves a lot of wiggle room for the browser makers. Today, virtually all browsers support using the Enter key to submit a form, whether the form contains one or more single line text input boxes.
The problem I'm having is more or less unique to Internet Explorer, and only when the form contains one, single-line text input control. For whatever reason, Microsoft decided that when Internet Explorer submits a form like this, it doesn't include the submit button's name/value pair in the post body. However, it does include the button's name/value pair if the user clicks the submit button --or-- uses the Enter key, and the form contains more than one single-line text input control.
So, the only solution I can think of or find suggested is to add a second single-line text input to my form, and then set the the style to
visibility: hidden; display: none;
My form now has two single-line text input controls, so the form will post with the name/value pair in the form body, regardless of whether or not the user used the Enter key or clicked the submit button.
So, we have a workaround that was discovered by ASP.NET developers. It seems the key/value pair is required by ASP.NET web-forms to fire the click event, so this work around isn't something new, albeit not my favorite way to do things.
is it possible to skip the url field when tab button is pressed in a form?
like after it goes to the last input element i wanted it to go back to the first input element instead of going to the url field!
thanks a alot.
You can add an onkeyup on your last input and check if the tab-key was pressed and then run something like your_first_input.focus(), so that it jumps to the first input.